Utility class that measures the elapsed time. More...
#include <SFML/System/Clock.hpp>
Public Member Functions | |
Clock () | |
Default constructor. | |
Time | getElapsedTime () const |
Get the elapsed time. | |
Time | restart () |
Restart the clock. | |
Utility class that measures the elapsed time.
sf::Clock is a lightweight class for measuring time.
Its provides the most precise time that the underlying OS can achieve (generally microseconds or nanoseconds). It also ensures monotonicity, which means that the returned time can never go backward, even if the system time is changed.
Usage example:
The sf::Time value returned by the clock can then be converted to a number of seconds, milliseconds or even microseconds.
sf::Clock::Clock | ( | ) |
Default constructor.
The clock starts automatically after being constructed.
Time sf::Clock::getElapsedTime | ( | ) | const |
Time sf::Clock::restart | ( | ) |
Restart the clock.
This function puts the time counter back to zero. It also returns the time elapsed since the clock was started.