Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Utility class that measures the elapsed time. More...
#include <SFML/System/Clock.hpp>
Public Member Functions | |
Time | getElapsedTime () const |
Get the elapsed time. | |
bool | isRunning () const |
Check whether the clock is running. | |
void | start () |
Start the clock. | |
void | stop () |
Stop the clock. | |
Time | restart () |
Restart the clock. | |
Time | reset () |
Reset the clock. |
Utility class that measures the elapsed time.
sf::Clock is a lightweight class for measuring time.
The clock starts automatically after being constructed.
It 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.
|
nodiscard |
|
nodiscard |
Check whether the clock is running.
Time sf::Clock::reset | ( | ) |
Time sf::Clock::restart | ( | ) |
void sf::Clock::start | ( | ) |
Start the clock.
void sf::Clock::stop | ( | ) |
Stop the clock.