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

Author Topic: Should I make a clock for every entity?  (Read 1216 times)

0 Members and 1 Guest are viewing this topic.

Kain5056

  • Newbie
  • *
  • Posts: 26
    • View Profile
Should I make a clock for every entity?
« on: June 07, 2013, 11:41:37 am »
Hello everybody, I am quite new to SFML and programming in general, and I have a simple question to see if I undestand things right.

As I see in every tutorial, every time you want to animate an entity, you need to restart the clock after every animation cycle.

Does that mean that you need a seperate clock for every entity, or is there a way to use just one clock for all entities?

I have not found a Tutorial that specifies this issue yet, so I apologize if it is mentioned somewhere and I missed it.

Thank you in advance.  :)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Should I make a clock for every entity?
« Reply #1 on: June 07, 2013, 12:13:35 pm »
You don't need clocks for animations. You only need a single clock to measure the frame time, and pass that time to the animations.

You could also have a look at how I implemented animations in Thor: API documentation, bigger example. The animations take a sf::Time value and affect the sprite correspondingly.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Kain5056

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Should I make a clock for every entity?
« Reply #2 on: June 07, 2013, 12:37:15 pm »
Thanks for the help. :-) That's all I needed to know. :-)