admin管理员组

文章数量:1410730

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?

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?

Share Improve this question edited Jul 26, 2014 at 14:20 GDP2 asked Jul 25, 2014 at 16:03 GDP2GDP2 2,0183 gold badges23 silver badges39 bronze badges 3
  • 1 please somebody answer this question.. i also in need with the solution. thanks – Vainglory07 Commented Jul 26, 2014 at 7:51
  • 1 @Vainglory07 I was able to find an answer for this question – GDP2 Commented Jul 28, 2014 at 16:57
  • wooo finally :D thanks – Vainglory07 Commented Jul 31, 2014 at 2:29
Add a ment  | 

1 Answer 1

Reset to default 5

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];

本文标签: javascriptGiving sprites an overlay in the Phaser frameworkStack Overflow