SFML community forums
Help => General => Topic started by: Ionut on May 20, 2017, 06:30:08 pm
-
Hello! I have a problem, an animation one more precisely.The problem is that when I press Left for example it moves and animates the sprite,but the animation is really fast, how to fix that?
-
Put more delay between animation frames.
-
How ?
-
to answer that we'd need to know how you handle animation.
but one suggestion could be to use the sf::Clock or you could increase animation frame by less than a whole eg:
CurrentFrame (a float)
DisplayFrame (an int)
CurrentFrame += 0.1;
if(CurrentFrame >= 3) CurrentFrame = 1;
DisplayFrame = (int)CurrentFrame;
this code will loop DisplayFrame between 1 and 2 for each 10 updates. likevise:
CurrentFrame += 0.25;
if(CurrentFrame >= 6) CurrentFrame = 1;
DisplayFrame = (int)CurrentFrame;
will loop between between 1,2,3,4 and 5, for each 4 updates.
-
Thanks, it worked ;D