SFML community forums

Help => General => Topic started by: Ionut on May 20, 2017, 06:30:08 pm

Title: [SOLVED]Animation Problem
Post 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?
Title: Re: Animation Problem
Post by: Laurent on May 20, 2017, 06:52:28 pm
Put more delay between animation frames.
Title: Re: Animation Problem
Post by: Ionut on May 20, 2017, 06:54:21 pm
How ?
Title: Re: Animation Problem
Post by: GameBear on May 20, 2017, 08:03:37 pm
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.
Title: Re: Animation Problem
Post by: Ionut on May 21, 2017, 11:04:48 am
Thanks, it worked  ;D