Options
All
  • Public
  • Public/Protected
  • All
Menu

Abstract Clock is the base type of all Clocks

It has a few opinions

  1. It manages the calculation of what "elapsed" time means and thus maximum fps
  2. The default timing api is implemented in now()

To implement your own clock, extend Clock and override start/stop to start and stop the clock, then call update() with whatever method is unique to your clock implementation.

Hierarchy

Index

Constructors

Properties

fpsSampler: FpsSampler
tick: ((elapsedMs: number) => any)

Type declaration

    • (elapsedMs: number): any
    • Parameters

      • elapsedMs: number

      Returns any

Methods

  • elapsed(): number
  • Get the elapsed time for the last completed frame

    Returns number

  • isRunning(): boolean
  • Returns if the clock is currently running

    Returns boolean

  • now(): number
  • schedule(cb: (() => any), timeoutMs?: number): void
  • Schedule a callback to fire given a timeout in milliseconds using the excalibur Clock

    This is useful to use over the built in browser setTimeout because callbacks will be tied to the excalibur update clock, instead of browser time, this means that callbacks wont fire if the game is stopped or paused.

    Parameters

    • cb: (() => any)

      callback to fire

        • (): any
        • Returns any

    • timeoutMs: number = 0

      Optionally specify a timeout in milliseconds from now, default is 0ms which means the next possible tick

    Returns void

  • setFatalExceptionHandler(handler: ((e: unknown) => any)): void
  • Parameters

    • handler: ((e: unknown) => any)
        • (e: unknown): any
        • Parameters

          • e: unknown

          Returns any

    Returns void

  • start(): void
  • Start the clock, it will then periodically call the tick(elapsedMilliseconds) since the last tick

    Returns void

  • stop(): void
  • update(overrideUpdateMs?: number): void