Clock class that has the semantics of a countdown timer. More...
Public Member Functions | |
Timer () | |
Default constructor: Creates a timer that is initially expired. More... | |
virtual | ~Timer () |
Virtual destructor. | |
sf::Time | getRemainingTime () const |
Returns the remaining time. More... | |
bool | isRunning () const |
Checks if the timer is currently running. More... | |
bool | isExpired () const |
Checks if the timer has expired yet. More... | |
void | start () |
Starts or continues the timer. More... | |
void | stop () |
Pauses the timer. More... | |
virtual void | reset (sf::Time timeLimit) |
Resets the timer's remaining time to the given limit and stops it. More... | |
virtual void | restart (sf::Time timeLimit) |
Resets the timer's remaining time to the given limit and starts it again. More... | |
Clock class that has the semantics of a countdown timer.
After starting the timer, it will automatically count down, until the remaining time reaches zero.
thor::Timer::Timer | ( | ) |
sf::Time thor::Timer::getRemainingTime | ( | ) | const |
Returns the remaining time.
If the timer has expired, sf::Time::Zero is returned.
bool thor::Timer::isExpired | ( | ) | const |
Checks if the timer has expired yet.
Timers expire when their remaining time reaches zero.
bool thor::Timer::isRunning | ( | ) | const |
Checks if the timer is currently running.
As soon as the timer expires, it stops running.
|
virtual |
Resets the timer's remaining time to the given limit and stops it.
timeLimit | The new time limit (must be greater than zero). |
In contrast to restart(), the timer is not running after the call.
Reimplemented in thor::CallbackTimer.
|
virtual |
Resets the timer's remaining time to the given limit and starts it again.
timeLimit | The new time limit (must be greater than zero). |
The behavior is equivalent to reset(timeLimit) followed by start().
Reimplemented in thor::CallbackTimer.
void thor::Timer::start | ( | ) |
Starts or continues the timer.
If it is already running, nothing happens.
void thor::Timer::stop | ( | ) |
Pauses the timer.
If it is already paused, nothing happens.