Stop sprite animations from playing? (SOLVED)

Hi guys!

Is there exactly a way to stop a playing animation? There’s a message named "play_animation" for the sprites which can let them to start, however I can’t find a message named like, say, "stop_animation"; or another method to reach this goal.

Thanks.

There’s go.cancel_animations(url, property).

2 Likes

Thanks for your reply! But could you give me an instance to show how to use this? I’m sorry for that I’m new to Defold.

Ah, sorry. I can see now that I misunderstood your question. “go.cancel_animations” would be used if you animated a game object using “go.animate”, but what you’re doing is a flip-book animation.

What I think you want is to do is to send another “play_animation” message and set the animation to just a static image.

If you need the flipbook animation to freeze at the exact image that’s displayed at the moment - I’m gonna let someone else answer that, as that’s not something I’ve tried before.

There isn’t stop_animation method for sprites. You can change your sprite to IDLE(single sprite) or you can set its playback_rate to 0

1 Like

@Klear and @selimanac Thank you all!

What I want is freeze at the exact image that’s displayed at the moment ; and we can set playback_rate to 0 now. My problem got fixed!

5 Likes

There’s now also a sprite.play_flipbook() that does the same thing.

1 Like

Any answer to this question? and how to get/set flipbook animation current frame number?

Check this out:

1 Like