Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • Timer

Index

Constructors

Properties

id: number = 0
interval: number = 10
maxNumberOfRepeats: number = -1
random: Random
randomRange: [number, number] = ...
repeats: boolean = false
scene: Scene<unknown> = null

Accessors

  • get complete(): boolean
  • get isRunning(): boolean
  • get timeElapsedTowardNextAction(): number
  • Returns number

    milliseconds elapsed toward the next action

  • get timeToNextAction(): number
  • Returns number

    milliseconds until the next action callback, if complete will return 0

  • get timesRepeated(): number

Methods

  • cancel(): void
  • Cancels the timer, preventing any further executions.

    Returns void

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

    Parameters

    • fcn: (() => void)

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

        • (): void
        • Returns void

    Returns void

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

    Parameters

    • fcn: (() => void)

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

        • (): void
        • Returns void

    Returns void

  • Pauses the timer, time will no longer increment towards the next call

    Returns Timer

  • reset(newInterval?: number, newNumberOfRepeats?: number): void
  • 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 completed

    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

  • Resumes the timer, time will now increment towards the next call.

    Returns Timer

  • Starts the timer, if the timer was complete it will restart the timer and reset the elapsed time counter

    Returns Timer

  • Stops the timer and resets the elapsed time counter towards the next action invocation

    Returns Timer

  • 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