Choose first frame of play_animation?

Is there a way to choose the first frame of an atlas flip-book animation? Here’s my use case:

I have a object who can walk in 4 directions (up,down,left,right). For each of these animations, the first frame is a left foot forward, second frame is right foot forward. If a user is rapidly changing direction, calling msg.post(…,“play_animation”) is going to constantly be resetting to the 1st frame of each animation, so it looks like the object is not really “walking”, but just standing on one leg and changing direction!

What I’d like to do is something like keep track of which frame is going and call something like msg.post(…,“play_animation”, {id = hash(“move_left”), frame=2}). Is there any way to do that, or another suggestion for how to accomplish this?

Would be a nice feature… in the mean time you can use animations as frames and animate between them yourself.

My recommendation would be to keep track of the currently playing animation and perhaps prevent the same animation from being played until the animation has completed (animation_done message). And if you have a separate walk_left and walk_right animation perhaps keep only the one and use sprite.set_hflip() to flip the sprite based on direction of movement.

2 Likes

The problem isn’t with calling the same animation, it’s switching animations. Thanks for the set_hflip(), that would work for switching between left/right but unfortunately not for up/down since they are not just mirror images. I might just need to go with @Pkeod 's suggestion and handle animation frames myself.

Lateral solution: have two animations sets and have each one start at a different point in the cycle.

I think this thread answers my question, but just to confirm:

I have a GO with multiple instances of the same animated sprite. I’d like to start the animation of each of these at a random frame to prevent them from being animated in sync. Is the only/best way to do this to make multiple animations manually?

The animation only has 5 frames so it isn’t much of a problem, but I can see this being problematic in other cases.

Yes, it is the only way to do it currently. (Well, I can think of a really weird way of achieving it but let’s not go down that route… :slight_smile:

See this post for future alternatives: Pixel Art Witchcrafter - RPG Puzzle Story

2 Likes