The Timer object provides a time-centered callback for your game.
The "recur" property allows you to have a Lua function called on a regular basis.
The "interval" property determines the time length between callbacks.
It must be greater than 0 or the timer will fail to start.
An active timer will keep running even after you lose all Lua references to it.
It will continue raising the callback event until the garbage collector kicks in.
Therefore, always stop your timers before you unreference them.
Desired time interval between callbacks in milliseconds. This is a number value (default is 0)
State of the timer. This is a boolean value (default is true)
Determines if the callback should be raised repeatedly. This is a boolean value (default is false)
- Timer ( [interval [, recur]] )
Creates a new timer object and assigns it an interval and a recurring option
- get_delta ( )
Returns the actual time the timer has been active between callbacks (or the initial start and the first callback) in fractional form from 1 to infinity
- get_delta_ms ( )
Returns the actual time the timer has been active between callbacks (or the initial start and the first callback) in milliseconds
- get_elapsed ( )
Returns the total time elapsed since the timer was initially started in milliseconds
- pause ( )
Pauses the timer
- stop ( )
Pauses the timer and clears the elapsed time
- start ( [interval [, recur]] )
Unpauses the timer.
The second parameter is optional and assigns the supplied interval in milliseconds.
The third parameter is also optional and sets the recurring option
- on_tick ( timer )
Called while the timer is in an active state.
Due to hardware differences between machines, there is no guarantee that this event will be raised precisely at the desired interval.
Your program should use "get_delta" or "get_delta_ms" to check the actual time elapsed between calls