如何减慢动画的速度,以便当精灵向右移动时,它看起来不像是在跳过?例如,当我按下右边时,我希望精灵看起来像是走到下一个瓷砖,而不是跳过。这是单击右键一次。目前这是我的功能,显示精灵。它处于while循环中,仅在用户退出时退出,因此不断被调用。
if( velocity < 0 )
{
//Set the animation to left
status = FOO_LEFT;
//Move to the next frame in the animation
frame++;
}
//If Foo is moving right
else if( velocity > 0 )
{
//Set the animation to right
status = FOO_RIGHT;
frame++;
}
//If Foo is moving up
else if(yvelocity<0)
{
//Set the animation to up
status = FOO_UP;
//Move to the next frame in the animation
frame++;
}
//If Foo is moving down
else if (yvelocity>0)
{
//Set the animation to down
status=FOO_DOWN;
//Move to the next frame in the animation
frame++;
}
//If Foo standing
else
{
//Restart the animation
frame = 0;
}
//Loop the animation
if( frame >= 4 )
{
frame = 0;
}
//Show the stick figure
if( status == FOO_RIGHT )
{
apply_surface( offSet, yoffset, foo, screen, &clipsRight[ frame ] );
}
else if( status == FOO_LEFT )
{
apply_surface( offSet, yoffset, foo, screen, &clipsLeft[ frame ] );
}
else if(status== FOO_UP)
{
apply_surface( offSet, yoffset, foo, screen, &clipsUp[ frame ] );
}
else if (status == FOO_DOWN)
{
apply_surface( offSet, yoffset, foo, screen, &clipsDown[ frame ] );
}