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

  • new Timer(fcn: function, interval: number, repeats?: boolean, numberOfRepeats?: number): Timer
  • Parameters

    • fcn: function

      The callback to be fired after the interval is complete.

        • (): void
        • Returns void

    • interval: number

      Interval length

    • Optional repeats: boolean

      Indicates whether this call back should be fired only once, or repeat after every interval as completed.

    • Optional numberOfRepeats: number

      Specifies a maximum number of times that this timer will execute.

    Returns Timer

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
  • Cancels the timer, preventing any further executions.

    Returns void

fcn

  • fcn(): void

getTimeRunning

  • getTimeRunning(): number

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