Stopping an animation on a particular frame

Hi!

I’m using an animation that is created with sprite.newSpriteSheetFromData(). I have a button to move the animation across the screen in the X axis. So far the only way I have found to stop the animation after ending the touch event is with spriteInstance:pause().

Is there a way to stop the animation on a particular frame? Right now the animation stops on whatever frame it happens to be on.

Thanks in advance for any input

Alan [import]uid: 93315 topic_id: 20791 reply_id: 320791[/import]

You would use pause but then do;

[lua]sprite.currentFrame = 1[/lua]

With 1 being the frame you want to display.

Peach :slight_smile: [import]uid: 52491 topic_id: 20791 reply_id: 81821[/import]

I created a callback system by using an event listener, one of the phases passed by the “sprite” event tells you when you’ve reached a new frame.

http://developer.anscamobile.com/reference/index/spriteinstanceaddeventlistener [import]uid: 100558 topic_id: 20791 reply_id: 81886[/import]

Thanks Peach! That worked perfectly. :wink:

Alan [import]uid: 93315 topic_id: 20791 reply_id: 81924[/import]

Not a problem Alan :slight_smile: [import]uid: 52491 topic_id: 20791 reply_id: 82127[/import]