Jump to content

To kill() a Sprite before kill animation?


mraak
 Share

Recommended Posts

Usually an object has an animation for the dying phase, maybe a second of explosion, or fading out. However when you call enemy.kill() it disappears completely from display, hence there can't be any dying animation played if the object is not visible.

 

Is it therefore a best practice to have the dying animation outside the sprite that you're killing, place it on the correct coordinate and play it? 

 

 

enemyDying.x = enemy.x;

enemyDying.y = enemy.y;

enemyDying.animations.play("die");

 

enemy.kill();

 

 

 

 

Link to comment
Share on other sites

When you add the animation, take the animation object reference and set killOnComplete to true.

Then just play the animation, don't call kill yourself.

 

From the docs (http://docs.phaser.io/Phaser.Animation.html):

  Properties: Name Type Description killOnComplete boolean

Should the parent of this Animation be killed when the animation completes?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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