I have a few animations defined for my character: running, rising, falling, etc.
In my setup phase, I get each animation into it's own instance:
runAnimation = skelData.findAnimation("running");
floatAnimation = skelData.findAnimation("floating");
fallAnimation = skelData.findAnimation("falling");
riseAnimation = skelData.findAnimation("rising");
dieAnimation = skelData.findAnimation("dying");
curAnimation = runAnimation;
Now when I want to have the player enter one of these animations, I use a method:
public void useAnimation(int whichAni){
switch(whichAni){
case RUN:
newAnimation = runAnimation;
...
//etc.
}
newAnimationTime = game.now();
mixDuration = 1.0f;
}
and in my render method:
public void render()
{
float alphaBlend = (newAnimationTime - game.now()) / blendDuration;
alphaBlend = Math.min(1, alphaBlend);
curAnimation.apply(....);
if(newAnimation != null)
newAnimation.mix(...., alphaBlend);
if(alphaBlend == 1)
{
curAnimation = newAnimation;
newAnimation = null;
}
}
The problem is that the character gets stuck in between states and the animations get all screwy. (ex. the characters feet get stuck in a certain position, even though my animation defines where they should be.) Is there anything obviously wrong I'm doing?
I am using libgdx.
Screen capture of how it looks:
With mixing:
http://youtu.be/-UIvk5kISIg
Without mixing:
http://youtu.be/iXXSpD9Vj8w