Need to reverse animation

Discussion and feedback on Construct 2

Post » Wed Aug 22, 2012 9:27 pm

I have a player that leans to the left or right based on the arrow keys. There are 9 frames with 4 being the default position when no arrow is down. I would like to animate from left to right or right to left seamlessly without having to use multiple animations.But there is no way to animate in reverse that I've seen.

I've noticed that there is a ping pong behavior for animations, but that's not completely what I'm looking for. Would be nice if I could animation from frame 0-5, 0-9, 5-0 based on need. I think the ability to have frame labels would be nice as well so you don't have to rely on numbers always.

Is there a way to do this currently?

Thanks for considering!
Posts: 20
Reputation: 2,378

Post » Wed Aug 22, 2012 10:40 pm

You could set the animation speed to 0 and animate manually via events.

when the player holds left
+every 0.2 seconds ---> set current frame to: max(currentFrame-1,0)

when the player holds right
+every 0.2 seconds ---> set current frame to: min(currentFrame+1,9)

when the player not holding left or right, add 1 if the current frame is <4 and subtract if the current frame is >4

assuming your animation is somewhat like this: _\|/_

you may need to tweak the "every 0.2 seconds" to speed up or slow down your animation.Fimbul2012-08-22 23:29:27
Posts: 532
Reputation: 6,898

Post » Wed Aug 22, 2012 10:44 pm

Yeah was missing this feature a few weeks back.
Your other option is to duplicate the animation, and reverse the order.
Might put in a request to @Ashley
If its not in his to do list already.
Image ImageImage
Posts: 7,809
Reputation: 85,572

Post » Thu Dec 29, 2016 4:00 am

I know this is an old post.

I was looking for this, I had the same question.
I typed out my questions and everything, I even posted them.
I then I realized the solution, so I edited this to give it.

You have to reverse the play speed of the animation.
I have my speed set to a Variable.
So when I need to reverse an animation I did this.

Set animation speed to -abs(SpeedVariable)

abs is "Absolute Value". It is a mathematical expression.

What it does is turn negative numbers positive.
So if you have a declining slope like this:
3, 2, 1, 0, -1, -2, -3

Using abs() will give you:
3, 2, 1, 0, 1, 2, 3

By putting a "-" in front of abs() it makes every number negative, like this:
-3, -2, -1, 0, -1, -2, -3

Therefore it reverses the animation speed.

You can then use Conditions
"Compare frame", "Compare speed", and "Is playing" to do what you need.

* Zero will always be 0. Zero can't be negative nor positive*
Posts: 182
Reputation: 9,896

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests