fitness23 Posted June 4, 2016 Share Posted June 4, 2016 I have a function that keeps repeating once every 5 seconds. In that function I have an animation that has some actions assigned in the oncomplete area. However I need to cancel this animation once it's complete so that the actions inside the oncomplete don't get assigned twice. Can I do something like this: var robotAttackAnim = enemy.animations.play('robotAttack'); robotAttackAnim.onComplete.add(function() { robotAttackAnim.destroy(); }, this); Please note I wish to keep using the animation frames "robotAttack" again, it's just I don't want to use the instance of "robotAttackAnim" as it'll be re-assigned the next time the function is called. Link to comment Share on other sites More sharing options...
fitness23 Posted June 4, 2016 Author Share Posted June 4, 2016 Sorry I got it eventually. I needed to use "addOnce". var robotAttackAnim = enemy.animations.play('robotAttack'); robotAttackAnim.onComplete.addOnce(function() { robotAttackAnim.destroy(); }, this); Link to comment Share on other sites More sharing options...
Recommended Posts