Jump to content

Low Hitpoints animation!


slash
 Share

Recommended Posts

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

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

  • 3 weeks later...

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...