Jump to content

Callback when animation complete?


seiyria
 Share

Recommended Posts

Looking at the signature for AnimationManager.play(name, frameRate, loop, killOnComplete), there doesn't appear to be a way to run a callback when an animation completes. Is there some other way to do this? If not, would it make sense to change this function to accept a callback (which could be sprite.kill)?

 

edit:

 

slightly unrelated, but there also doesn't appear to be a way to check if a sprite is animating except to check if it's currentFrame.index === original frame. Is that the right way to check it?

Link to comment
Share on other sites

Hi! 

Look at the events property of the sprite. There you find onAnimationStart, onAnimationComplete & onAnimationLoop

To check for a running animation use isFinished, isPaused, isPlaying on the animation instance itself (you get that reference to the animation when you call play)

animationReference = sprite.animations.play("name")animationReference.isPlaying

http://docs.phaser.io/Phaser.Animation.html

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...
  • 11 months later...
 Share

  • Recently Browsing   0 members

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