JackBid

Check animation frames / when finished

Recommended Posts

In one of the project I am working on. an animation is played when a sprite is colliding and the animation stops when the sprite exits collision. All I want to do is to check when the animation has reached the end (before is loops round again), or a simple method to check which frame an animation is on so I can check if it is on the last frame. So in other words, how you check which frame a sprite is on during an animation, or is there a way to check when a sprite has finished the animation before looping.

 

Thanks.

Share this post


Link to post
Share on other sites

 

Use the above suggestion to get the current frame, but you can also use these sprite events too:

sprite.events.onAnimationStartsprite.events.onAnimationCompletesprite.events.onAnimationLoop

 

why doesn't work it ?

player.animations.add('run')player.animations.play('run', 12, false, true);	    player.animations.onAnimationComplete.add(function(){			console.log("complete")		}, this);

Share this post


Link to post
Share on other sites

How do I chain sprite atlas animations? Example

 

this.game.load.atlasJSONArray('male', src + '/male.png', src + '/male.json');

....

 

this.male.animations.add('arrival', Phaser.Math.numberArray(0, 79));
this.male.animations.add('dustoff', Phaser.Math.numberArray(80, 144));
this.male.animations.add('scratch', Phaser.Math.numberArray(145, 189));
this.male.animations.add('tap', Phaser.Math.numberArray(190, 249));
 
I want to play arrival, and after complete, play dustoff... etc.etc

Share this post


Link to post
Share on other sites
Sorry to resurrect an old thread.
 
Using the below, how can I get the name of the animation that finished playing? I have multiple animations on a sprite and only want to do some behaviour with one of those animations and this event triggers for all of them.
this.spr.events.onAnimationComplete.add(function() {    console.log('animation complete');    if (is_walk_animation) { ... } }, this);

Thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.