Gleam - v1.0.2
    Preparing search index...

    Class Gameloop

    Fixed-step game loop. Owned by Game (game.gameloop) — usually started automatically by preInit() when Settings.autoloop is true. Each rendered frame:

    1. Accumulates real time
    2. Runs game.update(Settings.fps) zero-or-more times until the accumulator is drained (bounded by MAX_STEPS_PER_FRAME to avoid runaway catch-up)
    3. Clears the canvas (per Settings.doNotClear / Settings.useClearRect) and calls game.draw(context)

    Fires the EventSystem "gameloopStopped" event when teardown completes (not when stopLoop is called).

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    levelTime: number = 0

    Simulation time in milliseconds. Advances by Settings.fps * 1000 per update step, so it reflects simulated time, not wall-clock — paused/dropped frames don't add. Use this for time-driven spawning, animations, etc.

    Accessors

    • get isLooping(): boolean

      true while the rAF callback is registered. Goes false only after the final frame fires the "gameloopStopped" event.

      Returns boolean

    Methods

    • Begin the rAF loop. Throws if stopLoop was called but teardown hasn't completed yet — wait for the "gameloopStopped" event before restarting.

      Returns void

    • Request that the loop stop on its next tick. Asynchronous — the loop tears down on the following frame and dispatches "gameloopStopped" when done.

      Returns void