SFML community forums

Help => Graphics => Topic started by: ZeroAndOne on December 25, 2012, 10:40:46 pm

Title: WHAT DOES GetFrameTime() DO?
Post by: ZeroAndOne on December 25, 2012, 10:40:46 pm
What does GetFrameTime() do? and why don't I have this function in my SFML 2.0? If its been replaced by another function, what is the other function?
Title: Re: WHAT DOES GetFrameTime() DO?
Post by: Laurent on December 25, 2012, 10:44:50 pm
It does...
float frameTime = frameClock.GetElapsedTime();
frameClock.Restart();
return frameTime;
... that's why it was removed.
Title: Re: WHAT DOES GetFrameTime() DO?
Post by: ZeroAndOne on December 25, 2012, 10:54:54 pm
So is there a function that replaced it?
Title: Re: WHAT DOES GetFrameTime() DO?
Post by: G. on December 25, 2012, 11:00:00 pm
Nop. You'll have to do it yourself. See the end of the time tutorial (http://www.sfml-dev.org/tutorials/2.0/system-time.php) or search the forums (it's a recurrent topic) for examples.
Title: Re: WHAT DOES GetFrameTime() DO?
Post by: eXpl0it3r on December 25, 2012, 11:01:47 pm
No not a direct function, but the equivalent what Laurent has posted... ::)

// Outside the game loop
sf::Clock frameClock;

// Inside the game loop
sf::Time frameTime = frameClock.restart();
float seconds = frameTime.asSeconds();
// Obviously this could also get done directly without a sf::Time object.

Then again if you need it for physics you should think about a fixed time step. ;)