Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Timer

The Excalibur timer hooks into the internal timer and fires callbacks, after a certain interval, optionally repeating.

Hierarchy

  • Timer

Index

Constructors

constructor

Properties

complete

complete: boolean = false

id

id: number = 0

interval

interval: number = 10

maxNumberOfRepeats

maxNumberOfRepeats: number = -1

repeats

repeats: boolean = false

scene

scene: Scene = null

Static id

id: number = 0

Accessors

timesRepeated

  • get timesRepeated(): number

Methods

cancel

  • cancel(): void

getTimeRunning

  • getTimeRunning(): number

off

  • off(fcn: function): void
  • Removes a callback from the callback list to be fired after the interval is complete.

    Parameters

    • fcn: function

      The callback to be removed from the callback list, to be fired after the interval is complete.

        • (): void
        • Returns void

    Returns void

on

  • on(fcn: function): void
  • Adds a new callback to be fired after the interval is complete

    Parameters

    • fcn: function

      The callback to be added to the callback list, to be fired after the interval is complete.

        • (): void
        • Returns void

    Returns void

pause

  • pause(): void
  • Pauses the timer so that no more time will be incremented towards the next call

    Returns void

reset

  • reset(newInterval?: number, newNumberOfRepeats?: number): void
  • Resets the timer so that it can be reused, and optionally reconfigure the timers interval.

    Parameters

    • Optional newInterval: number

      If specified, sets a new non-negative interval in milliseconds to refire the callback

    • Optional newNumberOfRepeats: number

      If specified, sets a new non-negative upper limit to the number of time this timer executes

    Returns void

unpause

  • unpause(): void
  • Unpauses the timer. Time will now increment towards the next call

    Returns void

update

  • update(delta: number): void
  • Updates the timer after a certain number of milliseconds have elapsed. This is used internally by the engine.

    Parameters

    • delta: number

      Number of elapsed milliseconds since the last update.

    Returns void