A timer implementation, tightly integrated with the game loop. It automatically counts frames – an amount of update calls.

Used as a basis for BpxAnimatedSprite.

$timer

Static factories

  • Parameters

    • opts: {
          delayFrames: number;
          frames: number;
          loop: boolean;
          onGamePause: "pause" | "ignore";
          paused: boolean;
      }
      • delayFrames: number
      • frames: number
      • loop: boolean
      • onGamePause: "pause" | "ignore"
      • paused: boolean

    Returns BpxTimer

    $timer

Accessors

  • get framesLeft(): number
  • A an amount of frames left to be counted, decrementing down to 0.

    Returns number

  • get hasFinished(): boolean
  • Whether this timer has finished already. For looped timers this becomes true forever after the first pass.

    Returns boolean

  • get hasJustFinished(): boolean
  • Whether this timer has finished in the most recent game loop iteration. For looped timers this becomes true at the end of each pass.

    Returns boolean

  • get progress(): number
  • A progress of the counting, gradually incrementing from 0 to 1.

    Returns number

Methods