Skip to main content

TestClock

The TestClock is meant for debugging interactions in excalibur that require precise timing to replicate or test

Hierarchy

Index

Constructors

constructor

Properties

publicfpsSampler

fpsSampler: FpsSampler

Methods

publicelapsed

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


    Returns number

publicisRunning

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


    Returns boolean

publicnow

  • now(): number
  • Get the current time in milliseconds


    Returns number

run

  • run(numberOfSteps: number, overrideUpdateMs?: number): void
  • Run a number of steps that tick the clock, optionally specify an elapsed time in milliseconds


    Parameters

    • numberOfSteps: number
    • optionaloverrideUpdateMs: number

    Returns void

publicschedule

  • 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: (elapsed: number) => any

      callback to fire

      • timeoutMs: number = 0

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

      • timing: ScheduledCallbackTiming = 'preframe'

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

      Returns void

    publicsetFatalExceptionHandler

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

      • handler: (e: unknown) => any

        Returns void

      publicstart

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


        Returns void

      step

      • step(overrideUpdateMs?: number): void
      • Manually step the clock forward 1 tick, optionally specify an elapsed time in milliseconds


        Parameters

        • optionaloverrideUpdateMs: number

        Returns void

      publicstop

      • stop(): void
      • Stop the clock, tick() is no longer called


        Returns void

      publictoStandardClock

      publictoTestClock

      • Returns TestClock