Need to reverse animation

0 favourites
  • 4 posts
From the Asset Store
Ninja char for your game! Make your own Shinobi game with this art.
  • 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!

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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*

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)