PokéRogue
    Preparing search index...

    Class RequestAnimationFrame

    Abstracts away the use of requestAnimationFrame or setTimeout for the core game update loop, providing a unified interface regardless of which mechanism is in use.

    When requestAnimationFrame is available and not overridden, it is used to drive the game loop, which ties updates to the display refresh rate and pauses automatically when the tab is hidden. If forceSetTimeOut is enabled in the Game Config, setTimeout is used instead, which runs at a fixed interval regardless of visibility or display sync.

    This class is instantiated and managed automatically by the Phaser.Game instance.

    Index

    The callback to be invoked each step.

    delay: number

    The delay, in milliseconds, between each step when using setTimeout.

    isRunning: boolean

    True if RequestAnimationFrame is running, otherwise false.

    isSetTimeOut: boolean

    True if the step is using setTimeout instead of RAF.

    The RAF step function.

    Invokes the callback and schedules another call to requestAnimationFrame.

    stepTimeout: Function

    The SetTimeout step function.

    Invokes the callback and schedules another call to setTimeout.

    timeOutID: number | null

    The setTimeout or RAF callback ID used when canceling them.

    • Stops the step from running and clears the callback reference.

      Returns void

    • Starts the requestAnimationFrame or setTimeout process running.

      Parameters

      • callback: FrameRequestCallback

        The callback to invoke each step.

      • forceSetTimeOut: boolean

        Should it use SetTimeout, even if RAF is available?

      • delay: number

        The delay, in milliseconds, between each step when using setTimeout.

      Returns void

    • Stops the requestAnimationFrame or setTimeout from running.

      Returns void