Jump to content

To kill() a Sprite before kill animation?


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;








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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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