I have a basic platformer using Box2d that works great. However, I now want to stop using my default square, and implement some running and jumping animations.

How can I ensure that:

  • When running, the speed of the running sprite is correct with the current player speed, as to prevent the sprite from 'moonwalking'.
  • When jumping, play the correct frames at the right moments? I imagine I need to check the vertical velocity and if this is zero again while jumping I'm at the highest point, but how do I track where to initiate the landing animation?

1 Answer 1


You'll just have to adjust your frame time based on your speed (or use a different animation based on your sprite's velocity). As for jumping, you'd either have to play the animation after landing or make sure you know you're landing soon, e.g. by having an invisible physics object below your character that gets notified of collisions in advance (but which won't cause anything else to bounce or anything similar).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .