Jump to content

gray filter on one object


espace
 Share

Recommended Posts

hi,

is it possible to apply the gray filter only on one object and not to all the world as specify in the example.

var gray = game.add.filter('Gray');

    game.world.filters = [gray];

i try the same method on one sprite but that don't works for me.

have you a solution ?

thanks.

Link to comment
Share on other sites

hi samme,

thanks for your reply. i know jsfiddle but not codepen, it's funny

in fact i have two variable with the same name so the filter doesn't work for this reason :rolleyes:

how do you do to play with the saturate...i believe that :

sprite.filters.x=50

sprite.filters.y=50

works but that don't.....

have you an idea ?

Link to comment
Share on other sites

  • 2 months later...

hi,

i don't know why but now this filters doesn't work and i do the same than previous...

i tried with prototype and normal and the filter doesn't work.

is it something changed in Phaser about that ?

https://jsfiddle.net/espace3d/yzk3xvgk/

 

sprite = function(game,posx,posy,im,Group){
this.posx=posx
this.posy=posy	
	Phaser.Sprite.call(this,game,this.posx,this.posy,im)
	Group.add(this)
	this.grayfiltertop = game.add.filter('Gray')
	this.grayfiltertop.gray=1

}

sprite.prototype = Object.create(Phaser.Sprite.prototype)
sprite.prototype.constructor = sprite

////////////////////////////////////////////////////////

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });

function preload() {
	game.load.image('icon','https://s16.postimg.org/x73803eph/1_freepik.jpg');
	game.load.image('imag','https://s22.postimg.org/5v19iae75/logoveto.png');
	game.load.script('gray', 'https://cdn.rawgit.com/photonstorm/phaser/master/filters/Gray.js')
}

function create() {
	game.physics.startSystem(Phaser.Physics.ARCADE)

	var g1=game.add.group()
	var Sprite = new sprite(game,100,50,'icon',g1)
	Sprite.filters=[Sprite.grayfiltertop]


	var Sprite_without_pro=game.add.sprite(100,400,'icon')
	Sprite_without_pro.filters = [game.add.filter('Gray')]
}	









 

Link to comment
Share on other sites

Hi samme,

thanks but that seems not working always...for what i have read filters are not completely supported in Cocoonjs so i work differently and apply a tint effect with the color in grayscale.

it's a rustine but that work in all case.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...