Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED]Animation Problem  (Read 2568 times)

0 Members and 1 Guest are viewing this topic.

Ionut

  • Jr. Member
  • **
  • Posts: 59
  • Guess Who's Back ?
    • View Profile
    • Email
[SOLVED]Animation Problem
« 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?
« Last Edit: June 06, 2017, 08:05:58 pm by Boanc »
Guess Who's Back ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Animation Problem
« Reply #1 on: May 20, 2017, 06:52:28 pm »
Put more delay between animation frames.
Laurent Gomila - SFML developer

Ionut

  • Jr. Member
  • **
  • Posts: 59
  • Guess Who's Back ?
    • View Profile
    • Email
Re: Animation Problem
« Reply #2 on: May 20, 2017, 06:54:21 pm »
How ?
Guess Who's Back ?

GameBear

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
    • Email
Re: Animation Problem
« Reply #3 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.
string message = "some random dude";
cout << "I'm just " << message;

Ionut

  • Jr. Member
  • **
  • Posts: 59
  • Guess Who's Back ?
    • View Profile
    • Email
Re: Animation Problem
« Reply #4 on: May 21, 2017, 11:04:48 am »
Thanks, it worked  ;D
Guess Who's Back ?

 

anything