SFML - Simple and Fast Multimedia Library

SFML 2.6.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Loading...
Searching...
No Matches
Public Member Functions | List of all members
sf::Clock Class Reference
System module

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.

## Detailed Description

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:

sf::Clock clock;
...
Time time1 = clock.getElapsedTime();
...
Time time2 = clock.restart();
sf::Clock
Utility class that measures the elapsed time.
Definition Clock.hpp:42
sf::Clock::restart
Time restart()
Restart the clock.
sf::Clock::getElapsedTime
Time getElapsedTime() const
Get the elapsed time.
sf::Time::Time
Time()
Default constructor.

The sf::Time value returned by the clock can then be converted to a number of seconds, milliseconds or even microseconds.

See also
  sf::Time

Definition at line 41 of file Clock.hpp.

## Constructor & Destructor Documentation

## ◆ Clock()

sf::Clock::Clock | ( |  | ) |

Default constructor.

The clock starts automatically after being constructed.

## Member Function Documentation

## ◆ getElapsedTime()

Time sf::Clock::getElapsedTime | ( |  | ) | const

Get the elapsed time.

This function returns the time elapsed since the last call to restart() (or the construction of the instance if restart() has not been called).

Returns
  Time elapsed

## ◆ restart()

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.

Returns
  Time elapsed

The documentation for this class was generated from the following file:

- Clock.hpp