Timer
Index
Constructors
constructor
Parameters
options: TimerOptions
Returns Timer
Properties
publicid
publicinterval
publicmaxNumberOfRepeats
publicrandom
publicrandomRange
publicrepeats
publicscene
Accessors
publiccomplete
Returns boolean
publicisRunning
Returns boolean
publictimeElapsedTowardNextAction
Returns number
milliseconds elapsed toward the next action
publictimeToNextAction
Returns number
milliseconds until the next action callback, if complete will return 0
publictimesRepeated
Returns number
Methods
publiccancel
Cancels the timer, preventing any further executions.
Returns void
publicgetTimeRunning
Returns number
publicoff
Removes a callback from the callback list to be fired after the interval is complete.
Parameters
action: () => void
The callback to be removed from the callback list, to be fired after the interval is complete.
Returns void
publicon
Adds a new callback to be fired after the interval is complete
Parameters
action: () => void
The callback to be added to the callback list, to be fired after the interval is complete.
Returns void
publicpause
Pauses the timer, time will no longer increment towards the next call
Returns Timer
publicreset
Resets the timer so that it can be reused, and optionally reconfigure the timers interval.
Warning** you may need to call
timer.start()
again if the timer had completedParameters
optionalnewInterval: number
If specified, sets a new non-negative interval in milliseconds to refire the callback
optionalnewNumberOfRepeats: number
If specified, sets a new non-negative upper limit to the number of time this timer executes
Returns void
publicresume
Resumes the timer, time will now increment towards the next call.
Returns Timer
publicstart
Starts the timer, if the timer was complete it will restart the timer and reset the elapsed time counter
Returns Timer
publicstop
Stops the timer and resets the elapsed time counter towards the next action invocation
Returns Timer
publicupdate
Updates the timer after a certain number of milliseconds have elapsed. This is used internally by the engine.
Parameters
elapsedMs: number
Number of elapsed milliseconds since the last update.
Returns void
The Excalibur timer hooks into the internal timer and fires callbacks, after a certain interval, optionally repeating.