- Timers allow you to set a delay and a callback to be called when the timer completes.
The timers created with this API are updated with the collection timer where they
are created. If you pause or speed up the collection (using set_time_step) it will also affect the new timer.
Static methods
staticcancel(handle:TimerHandle):Bool
- Cancel a timer.
You may cancel a timer from inside a timer callback. Cancelling a timer that is already executed or cancelled is safe.
Parameters:
| handle | the timer handle returned by timer.delay() | 
|---|
Returns:
true if the timer was active, false if the timer is already cancelled / complete
staticinlinedelay(delay:Float, repeat:Bool, callback:(handle:TimerHandle, timeElapsed:Float) ‑> Void):TimerHandle
- Create a timer.
Adds a timer and returns a unique handle
You may create more timers from inside a timer callback.
Using a delay of 0 will result in a timer that triggers at the next frame just before script update functions.
If you want a timer that triggers on each frame, set delay to 0.0f and repeat to true.
Timers created within a script will automatically die when the script is deleted.
Parameters:
| delay | time interval in seconds | 
|---|---|
| repeat | true = repeat timer until cancel, false = one-shot timer | 
| callback | timer callback function | 
Returns:
identifier for the create timer, returns TimerHandle.Invalid if the timer can not be created
staticgetInfo(handle:TimerHandle):TimerInfo
- Get information about timer.
Parameters:
| handle | the timer handle returned by  | 
|---|
Returns:
the timer info, or null if timer is cancelled/completed
statictrigger(handle:TimerHandle):Bool
- Manual triggering a callback for a timer.
Parameters:
| handle | the timer handle returned by  | 
|---|
Returns:
true if the timer was active, false if the timer is already cancelled / complete