slash Posted September 11, 2014 Share Posted September 11, 2014 Hello all! I am thinking on adding a low hitpoints animation to my game, what I'd like is to tween the alpha back and forth for a full red sprite placed over the player, using the player sprite as a mask. Anyone has an idea how I could accomplish this using phaser? Thank you! Link to comment Share on other sites More sharing options...
slash Posted September 11, 2014 Author Share Posted September 11, 2014 I just did this like this: Player.prototype.redBlink = function(){if (this.isBlinking)return;this.isBlinking = true;var colorBlend = {step: 0};this.colorTween = this.gameController.tween(colorBlend).to({step:100}, 1000, Phaser.Easing.Sinusoidal.Out, false, 0, Number.MAX_VALUE, true);var thus = this;var tween = this.colorTween;this.colorTween.onUpdateCallback(function() {thus.sprite.tint = Phaser.Color.interpolateColor(0xFFFFFF, 0xFF0000, 100, colorBlend.step);if (colorBlend.step == 0 && tween.pleaseDie){tween.stop();thus.isBlinking = false;} });this.colorTween.start();};Player.prototype.stopBlink = function(){if (this.isBlinking)this.colorTween.pleaseDie = true;}; Link to comment Share on other sites More sharing options...
JUL Posted September 11, 2014 Share Posted September 11, 2014 It's a lot of process for some relatively trivial thing that should rather be done directly on the sprite sheet if you ask me. Link to comment Share on other sites More sharing options...
nkholski Posted October 3, 2014 Share Posted October 3, 2014 I curious if anyone has a cheaper solution for this without editing sprites. I want to show when enemies that requires multi-hits somehow, preferably that they flash in a brighter color half a second or something when being hit. Without doing this programmatically this will require a complete alternative spritesheet to cover all animations. Link to comment Share on other sites More sharing options...
Recommended Posts