Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Giving sprites an overlay in the Phaser framework

I'm trying to have a certain scene in my game where all of the game sprites have a gray overlay on them. I thought about just creating a gray version of each sprite, but then I realized that is not very DRY or easy. I need this overlay for both a singular sprite, like so:

sprite = game.add.sprite(x, y, "name_of_sprite");

And I need it for a group:

group = game.add.group();

How do you this in context of phaser?

like image 776
GDP2 Avatar asked Jul 25 '14 16:07

GDP2


1 Answers

Either one of these solutions will do the trick:

Sprite tinting

yourSpriteName.tint = color;

Gray filter example

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

yourSpriteName.filters = [gray];
like image 77
GDP2 Avatar answered Oct 25 '22 18:10

GDP2