class flixel.util.FlxTimer implements IFlxDestroyable
Available on all platforms
A simple timer class, leveraging the new plugins system. * Can be used with callbacks or by polling the finished flag. * Not intended to be added to a game state or group; the timer manager * is responsible for actually calling update(), not the user.
Class Fields
Instance Fields
var elapsedTime:Float
Read-only: The amount of milliseconds that have elapsed since the timer was started
function new(?Time:Float = null, ?Callback:FlxTimer ->Void = null, ?Loops:Int = 1):Void
Creates a new timer (and calls start() right away if Time != null). * *
Time | How many seconds it takes for the timer to go off. * |
Callback | Optional, triggered whenever the time runs out, once for each loop. Callback should be formed "onTimer(Timer:FlxTimer);" * |
Loops | How many times the timer should go off. 0 means "looping forever". |
function complete(:FlxTimer):Void
Function that gets called when timer completes. * Callback should be formed "onTimer(Timer:FlxTimer);"
function reset(?NewTime:Float = -1):FlxTimer
Restart the timer using the new duration *
NewDuration | The duration of this timer in ms. |
function start(?Time:Float = 1, ?Callback:FlxTimer ->Void = null, ?Loops:Int = 1):FlxTimer
Starts the timer and adds the timer to the timer manager. * *
Time | How many seconds it takes for the timer to go off. * |
Callback | Optional, triggered whenever the time runs out, once for each loop. Callback should be formed "onTimer(Timer:FlxTimer);" * |
Loops | How many times the timer should go off. 0 means "looping forever". * |
returns | A reference to itself (handy for chaining or whatever). |