mwg API
    Preparing search index...

    Class Game

    The application: owns the renderer, the loop, and the current scene.

    Construct it, await start(FirstScene), and the rest is scenes.

    Index
    app: Application<Renderer> = ...
    elapsed: number = 0

    seconds elapsed in the previous frame, clamped by maxDelta

    onFrame: Signal<number> = ...

    fires after every frame's update, for systems that are not scene-owned

    timeScale: number = 1

    multiplies elapsed time; 0 pauses the game without stopping the renderer

    timeTotal: number = 0

    total seconds since the current scene was created

    • get width(): number

      the viewport width in css pixels, which is what scenes lay out against

      Returns number

    • Briefly dips timeScale toward scale for duration real seconds, then restores it to 1 - a heavy hit's momentary freeze-frame, distinct from render.Camera.shake (which moves the view, not the clock) and from ui.FloatingText (a damage number, not a time effect). A second call while one is still running simply replaces it, the same way Camera.shake restarts rather than stacking.

      Parameters

      • duration: number
      • scale: number = 0

      Returns void

    • Queues the top scene's removal; it happens at the start of the next frame.

      Parameters

      • Optionalresult: unknown

        reported back to the resumed scene's onResume

      Returns void

    • Queues a scene on top of the current one; it starts at the next frame.

      The scene underneath suspends but is not destroyed: it stops updating and keeps rendering, so the new scene can layer over it or replace it outright, and popScene resumes exactly where play left off.

      Parameters

      Returns void

    • Advances the game by one frame and draws it, without waiting for the browser.

      The loop normally runs on requestAnimationFrame, which browsers suspend while a tab is not visible. That is right for a game and wrong for a test or a screenshot, so this drives a frame directly.

      Parameters

      • dt: number

        seconds to advance by

      Returns void

    • Queues a scene change; it happens at the start of the next frame.

      The whole stack goes: every scene is destroyed, suspended or not, and the new one starts alone. For a scene that returns, push it instead.

      Parameters

      Returns void