mraak Posted April 25, 2014 Share Posted April 25, 2014 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 More sharing options...
jpdev Posted April 25, 2014 Share Posted April 25, 2014 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 More sharing options...
mraak Posted April 25, 2014 Author Share Posted April 25, 2014 But the problem is that tween doesn't have killOnComplete, I guess I can kill() explicitly in an onComplete event. Link to comment Share on other sites More sharing options...
Recommended Posts