lxgui
|
A repeating timer. More...
#include <utils_periodic_timer.hpp>
Public Types | |
enum class | start_type { paused , now , first_tick } |
Public Member Functions | |
periodic_timer (double duration, start_type type, bool ticks_now) | |
Default constructor. | |
double | get_elapsed () const |
Returns the time elapsed since the last tick. | |
double | get_period () const |
Returns the period of the periodic_timer. | |
bool | is_paused () const |
Cheks if this periodic_timer is paused. | |
bool | ticks () |
Checks if the timer's period has been reached. | |
void | stop () |
Pauses the timer and resets it. | |
void | start () |
Starts the timer but doesn't reset it. | |
void | pause () |
Pauses the timer. | |
void | zero () |
Resets the timer but doesn't pause it. | |
void | update (double delta) |
Updates this timer (adds time). | |
A repeating timer.
This timer is meant to tick periodicaly, so you can use it for any periodic event such as key repetition or a count down.
Definition at line 14 of file utils_periodic_timer.hpp.
|
strong |
Enumerator | |
---|---|
paused | The timer will start if you call start() |
now | The timer starts immediatly after it is created. |
first_tick | The timer will start when you first call ticks() |
Definition at line 16 of file utils_periodic_timer.hpp.
lxgui::utils::periodic_timer::periodic_timer | ( | double | duration, |
start_type | type, | ||
bool | ticks_now | ||
) |
Default constructor.
duration | The time interval between each tick |
type | See TimerType |
ticks_now | The timer ticks immediately |
Definition at line 5 of file utils_periodic_timer.cpp.
double lxgui::utils::periodic_timer::get_elapsed | ( | ) | const |
Returns the time elapsed since the last tick.
Definition at line 11 of file utils_periodic_timer.cpp.
double lxgui::utils::periodic_timer::get_period | ( | ) | const |
Returns the period of the periodic_timer.
Definition at line 15 of file utils_periodic_timer.cpp.
bool lxgui::utils::periodic_timer::is_paused | ( | ) | const |
Cheks if this periodic_timer is paused.
Definition at line 19 of file utils_periodic_timer.cpp.
void lxgui::utils::periodic_timer::pause | ( | ) |
Pauses the timer.
Definition at line 43 of file utils_periodic_timer.cpp.
void lxgui::utils::periodic_timer::start | ( | ) |
Starts the timer but doesn't reset it.
Definition at line 47 of file utils_periodic_timer.cpp.
void lxgui::utils::periodic_timer::stop | ( | ) |
Pauses the timer and resets it.
Definition at line 38 of file utils_periodic_timer.cpp.
bool lxgui::utils::periodic_timer::ticks | ( | ) |
Checks if the timer's period has been reached.
Definition at line 23 of file utils_periodic_timer.cpp.
void lxgui::utils::periodic_timer::update | ( | double | delta | ) |
Updates this timer (adds time).
delta | The time elapsed since last update |
Definition at line 55 of file utils_periodic_timer.cpp.
void lxgui::utils::periodic_timer::zero | ( | ) |
Resets the timer but doesn't pause it.
Definition at line 51 of file utils_periodic_timer.cpp.