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

Author Topic: WHAT DOES GetFrameTime() DO?  (Read 2008 times)

0 Members and 1 Guest are viewing this topic.

ZeroAndOne

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
WHAT DOES GetFrameTime() DO?
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: WHAT DOES GetFrameTime() DO?
« Reply #1 on: December 25, 2012, 10:44:50 pm »
It does...
float frameTime = frameClock.GetElapsedTime();
frameClock.Restart();
return frameTime;
... that's why it was removed.
Laurent Gomila - SFML developer

ZeroAndOne

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: WHAT DOES GetFrameTime() DO?
« Reply #2 on: December 25, 2012, 10:54:54 pm »
So is there a function that replaced it?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: WHAT DOES GetFrameTime() DO?
« Reply #3 on: December 25, 2012, 11:00:00 pm »
Nop. You'll have to do it yourself. See the end of the time tutorial or search the forums (it's a recurrent topic) for examples.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: WHAT DOES GetFrameTime() DO?
« Reply #4 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. ;)
« Last Edit: December 25, 2012, 11:06:58 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/