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.

Look at this sprite sheet.

Megaman

It is clear that frame 1-3 are the "jump up" frames after which the last frame will be fixed until the "peak" of the jump (when gravity starts pulling back). When moving back down frame 4-7 are used and it all ends with an "idle" frame (which is not shown here in this jump sprite).

My question is about frame 6 and 7 in this sprite. When the entity "lands" after a jump it is suppose to run animation 6-7 as the "landing" animation. When moving down in a jump frame 4-5 are easy because they are the "start" of the animation. Frame 5 can be kept for as long as you fall... but what is the appropriate way to go from frame 5 to 6-7-x? Do you check if the frame after the next is a fall and then "initiate" landing or do you do that when you have actually hit the ground?

It can't be timed because of various scenarios such as jumping off a cliff or jumping under a low roof hitting your head and bouncing you back down.

Any ideas?

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

I guess the usual approach is to have three jump-related states: Jumping (a hero rises to the highest point of jump), Falling (from the highest point of jump to the ground), Landing (jump ends with hero standing on the ground).

There are several ways of detecting these states, usually it's a several collision checks setting state flags. For example, in a character's physics step we may check for collisions below, and if there aren't any, then character is in the air. Now if a character has positive vertical speed, it's a Jumping state, otherwise it's a Falling state. If it's a Falling state, and we detected a collision below, than it's a Landing state, so lets switch to the landing animation.

This animation usually plays when hero has actually hit the ground. The animation sequence is short, so landing will look high-speed, also it creates a feeling of crisp and precise controls. Sometimes character can do a long landing sequence, but then it's possible for a character to cancel landing animation and start running, e.g. Castlevania: SotN.

share|improve this answer
    
+1. Good point about states. From states you can figure out other details / modes. –  Krom Stern Aug 19 '11 at 18:36
    
Thank you for your help. –  sPirc Aug 21 '11 at 9:13
add comment

I've seen this done two ways:

  1. When the bounding box first collides with the ground make a fast transition 5->6->7.
  2. Have a second 'ghost' bounding box, that extends a small portion below the actual bounding box to initiate the 5->6, then upon the actual bounding box colliding do 6->7.
share|improve this answer
    
Liked the 2nd case. Seems very flexible because the ghost bounding box can be set far away depending on the speed of the character! –  pek Aug 19 '11 at 17:24
    
Interesting approach Nbr 2. I never ended up trying it but i will keep it in mind thank you. –  sPirc Aug 21 '11 at 9:14
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.