This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by NeilHighley


I'm trying to insert a death animation before kill is called and after receiveDamage is checked.

I have tried adding an onAnimationStopped callback to the death animation but it can't find the entity in the kill command.


in Animation.js;

if( this.stop && this.loopCount > 0 ) {
else {

and in the entity child class (the enemy sprite);

this.anims.die.onAnimationStopped=this.onDied; //hookup the callback
onDied:function(){ this);
// alert("he died");

The alert is fired when I uncomment it, but I can't see the scope to remove the entity.

Can anyone help?


1 decade ago by jminor

I recommend spawning a separate entity that displays the death animation. That way your enemy sprite dies right away and is replaced with an explosion or whatever. The logic for each can be kept separate which makes them each simpler.

1 decade ago by NeilHighley

cool, and how do I make that entity kill itself after the death animation has run its course?

1 decade ago by NeilHighley

Thanks for your help jMinor, here is what I did.

I spawned a new, death, Entity during the extended kill function of my sprite Entity.

In that death entity, I set the death animation to stop, by adding a true after the frame array.
Then during the "update" extended function, I checked for loopCount>0, which means that the animation has got to the end of the first loop.

Then , I simply called kill on the death entity.


update: function() {

I hope this helps one y'all.

1 decade ago by jminor

Nice. You could also use an ig.Timer.
Page 1 of 1
« first « previous next › last »