Clock class that has the semantics of a timer. More...
Public Member Functions | |
Timer () | |
Default constructor: Creates a timer that is initially expired. | |
virtual | ~Timer () |
Virtual destructor. | |
Timer (float timeLimit, bool initiallyRunning=false) | |
Constructor: Sets up a new timer with the given time limit. | |
float | GetRemainingTime () const |
Returns the remaining time. | |
bool | IsRunning () const |
Checks if the timer is currently running. | |
bool | IsExpired () const |
Checks if the timer has expired yet. | |
void | Start () |
Starts or continues the timer. | |
void | Stop () |
Pauses the timer. | |
virtual void | Reset (float timeLimit, bool continueRunning=false) |
Resets the timer's countdown to the given time limit. |
Clock class that has the semantics of a timer.
You can initialize an instance with a time limit and it will automatically count down, until the time reaches zero.
Default constructor: Creates a timer that is initially expired.
You have to call Reset() before you can use the countdown functionality.
thor::Timer::Timer | ( | float | timeLimit, |
bool | initiallyRunning = false |
||
) | [explicit] |
Constructor: Sets up a new timer with the given time limit.
timeLimit | The initial time (must be greater than zero). |
initiallyRunning | Indicates whether the timer is immediately being started. |
float thor::Timer::GetRemainingTime | ( | ) | const |
Returns the remaining time.
If the timer has expired, 0.f 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 until Reset() is called.
virtual void thor::Timer::Reset | ( | float | timeLimit, |
bool | continueRunning = false |
||
) | [virtual] |
Resets the timer's countdown to the given time limit.
timeLimit | The new time (must be greater than zero). |
continueRunning | Indicates whether the timer directly continues. |
Reimplemented in thor::TriggeringTimer.
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.