JackBid Posted November 23, 2013 Share Posted November 23, 2013 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. Link to comment Share on other sites More sharing options...
Mike Posted November 23, 2013 Share Posted November 23, 2013 http://gametest.mobi/phaser/docs/Phaser.Animation.html Check :isFinishedcurrentFrameframeThis three things could do the work.You can check them in the update knowing which one is your last frame. Link to comment Share on other sites More sharing options...
rich Posted November 24, 2013 Share Posted November 24, 2013 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 Lypzis 1 Link to comment Share on other sites More sharing options...
rodrigezer Posted December 18, 2013 Share Posted December 18, 2013 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); Link to comment Share on other sites More sharing options...
rich Posted December 18, 2013 Share Posted December 18, 2013 onAnimationComplete is a property of the Sprite.events object, try this:player.events.onAnimationComplete.add(function(){ console.log("complete") }, this); JackBid 1 Link to comment Share on other sites More sharing options...
changalberto Posted January 27, 2014 Share Posted January 27, 2014 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 Link to comment Share on other sites More sharing options...
gwinnell Posted February 10, 2014 Share Posted February 10, 2014 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! AmAuron 1 Link to comment Share on other sites More sharing options...
JUL Posted August 29, 2014 Share Posted August 29, 2014 Hi this is my first post @gwinnell sprite.animations.currentAnim.name returns the name of the current animation Link to comment Share on other sites More sharing options...
Recommended Posts