2d sprite animation end frame

How can i get end frame of sprite animation
For example i pressed up button than jump animation played than i want to know when it is ended.

I dont think im fully understanding wym?
You want to know how to end the animation or you want to know when the animation ends after the button is clicked?

Movement.prototype.update = function(dt)
{

    var up = this.app.keyboard.isPressed(pc.KEY_UP);

if (up) {
this.entity.sprite.play(‘JumpChar’);
}
}
This is my jump animation. And i have 8 sprite of animation so how can i get that animation has finished.

Hmmm try this instead of using up as a variable:

if (this.app.keyboard.wasPressed(pc.KEY_UP)) {
this.entity.sprite.play('JumpChar');
} else {
this.entity.sprite.stop('JumpChar');
}

Also could you post a link to your project? or is it private?

1 Like

Hi Amit,

You need to get access to the clip that is currently being played ( your jump clip ) when you call sprite.play

this.currentClip = this.entity.sprite.clip("nameOfJumpClip_REPLACE_THIS");

Then, in the update loop, check to see if the clip is playing - if it isn’t, then it has finished.

if(!this.currentClip.isPlaying)
{
    // Code to handle end of animation
}
1 Like

try this to do something when animation is ending

this.entity.sprite.on('end', function () {
    // Code to handle end of animation
});