Here is a solution that just replaces the entire texture with a solid color:
sprite.texture = PIXI.Texture.WHITE
Obviously this wont work with transparent sprites. Any transparency ends up solid as well. (Resulting in a solid rectangle)
How could I change the color of only non transparent pixels of the sprite?
(tint wont work either since all sprites would have to be white)
As far as I know, you can't do it with Pixi. According to one of Pixi maintainers here, you can use dark tint from pixi-heaven package (https://github.com/gameofbombs/pixi-heaven). This exact example is listed in its readme:
Make whole sprite of one color:
sprite.tint = 0xffaacc; sprite.color.dark[0] = sprite.color.light[0]; sprite.color.dark[1] = sprite.color.light[1]; sprite.color.dark[2] = sprite.color.light[2]; //dont forget to invalidate, after you changed dark DIRECTLY sprite.color.invalidate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With