1 decade ago by NeilHighley
Hi,
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.
e.g.
in Animation.js;
if( this.stop && this.loopCount > 0 ) {
-----
this.onAnimationStopped.call();//callback
}
else {
---
}
and in the entity child class (the enemy sprite);
kill:function(){
this.anims.die.onAnimationStopped=this.onDied; //hookup the callback
this.currentAnim=this.anims.die;
},
onDied:function(){
ig.game.removeEntity( 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?
Neil
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.
e.g.
in Animation.js;
if( this.stop && this.loopCount > 0 ) {
-----
this.onAnimationStopped.call();//callback
}
else {
---
}
and in the entity child class (the enemy sprite);
kill:function(){
this.anims.die.onAnimationStopped=this.onDied; //hookup the callback
this.currentAnim=this.anims.die;
},
onDied:function(){
ig.game.removeEntity( 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?
Neil