piotr Posted September 10, 2015 Share Posted September 10, 2015 Hi, I'd like to change color values of bitmap gradients over time or based on player's position (e.g. a torch is becoming redder over time or brighter the deeper we go). The code below of course doesn't work, but I'ma at loss in which direction looking for. var fade = Math.round(this.player.y / 10, 0);maskGradient.addColorStop(0, 'rgb( 255 - fade, 255 - fade, 255 - fade)'); maskGradient.addColorStop(1, 'rgb(50 - fade, 50 - fade, 50 - fade)'); What would be the best approach?Thanksp. Link to comment Share on other sites More sharing options...
icp Posted September 10, 2015 Share Posted September 10, 2015 http://phaser.io/docs/2.4.3/Phaser.Color.html#.interpolateRGBI think this will work for you. I used interpolateColor to change a sprite color based on its velocity and it worked well. Link to comment Share on other sites More sharing options...
piotr Posted September 10, 2015 Author Share Posted September 10, 2015 Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts