Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?
share|improve this question
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.