Skip to content
Advertisement

How can I stop animation loop, but not mid-animation in Phaser 3?

I have an animation, which usually is supposed to play 3 times, thus the config currently says repeat: 2. However, under a certain condition (the player stops dragging an element) I want the animation to finish and stop without repeating.

By that I mean I don’t want it to stop right at the frame it is at the second, but I want it to finish playing to the last frame I assigned in frames and then stop before it repeats.

How would I be able to do this?

JavaScript

Advertisement

Answer

You can use the function stopAfterRepeat (documentation).
Just call it with the parameter 0, and the current animation will be finished, before the animation is stopped. I think this is what you are after.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement