How does one usually handle animations that are for going between a game object's states? For example, imagine a very simple game in which a character can only crouch or stand normally. Currently, I use a custom Animation class like this:

class Animation{
 int numFrames;
 int curFrame;
 Bitmap spriteSheet;
 //... various functions for pausing, returning frame, etc.

and an example Character class

class Character{
 int state;
 Animation standAni;
 Animation crouchAni;
 //... etc, etc.

Thus, I use the state of the character to draw the necessary animation.

if(state == STATE_STAND)
else if(state == STATE_CROUCH)

Now I've come to the point where I want to draw "in-between" animations, because right now the character will just jump immediately into a crouch instead of bending down. What is a good way to handle this? And if the way that I handle storing Animations in the Character class is not a good way, what is?

I thought of creating states like STATE_STANDING_TO_CROUCHING but I feel like that may get messy fast.

  • \$\begingroup\$ I found this question: gamedev.stackexchange.com/questions/8537/… . I guess the answer is to push "crouching" then "crouched" to a queue system and have the system decide when to switch from one state to the next. If anyone has any better ideas, I still would like to hear them. \$\endgroup\$
    – you786
    Jun 20, 2011 at 5:40
  • \$\begingroup\$ You can, if you decide you have found the solution yourself, post your own solution as an answer (and accept it as well, if nobody posts a better one). Welcome to the site! \$\endgroup\$
    – user1430
    Jun 20, 2011 at 15:42

2 Answers 2


In between states are still states, more in general transient states should be modelled as states if their duration exeedes the frame duration; otherwise one should consider if appropriate on a case by case basis.


If anyone is curious, this is how I ended up implementing it:

USing my example, I got rid of exclusive playerStates, and simply used different boolean flags like isCrouched.

Then I would have something like this in my PlayerObject's update() function

    if(currentAnimation == startingCrouchAnimation && startingCrouchAnimation.isFinished())
        currentAnimation = crouchedAnimation;

and to draw the animation

  • \$\begingroup\$ +1 to Fxlll's answer, I don't see why the between-crouching-and-standing animation needs to be a special case - how is it different from any other animation state? \$\endgroup\$ Jul 4, 2011 at 1:56
  • \$\begingroup\$ Well I guess it's because my implementation uses the playerState for more than just animation/drawing, it also used it for physics logic. So if I used different states for between-crouching-and-standing and crouching, I would have huge if statements to decide if the player is crouching: if(playerState == betwee..-standing || playerState == crouching || etc. etc.) \$\endgroup\$
    – you786
    Aug 3, 2011 at 22:36

You must log in to answer this question.

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