@ujjwalvivek/tinyts
    Preparing search index...

    Class SceneManager

    Stack-based scene manager.

    Supports push/pop/replace operations with automatic onEnter/onExit lifecycle. Only the topmost scene receives update(). call sm.update(dt) from your game loop. render() behaviour depends on renderMode.

    const sm = new SceneManager({ renderMode: 'stack' });
    sm.push(new MenuScene('menu'));

    engineStart({
    update(dt) { sm.update(dt); },
    render() { sm.render(); },
    });

    sm.push(new GameScene('level1'));
    sm.push(new PauseScene('pause')); // game still visible underneath
    sm.pop(); // back to game
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    • get current(): Scene | undefined

      Currently active scene (top of stack), or undefined if empty.

      Returns Scene | undefined

    • get depth(): number

      Number of scenes on the stack.

      Returns number

    Methods

    • Remove all scenes from the stack.

      Returns void

    • Pop the top scene from the stack. The popped scene is destroyed (onExit called), the previous scene resumes (onEnter called).

      Returns Scene | undefined

    • Push a new scene onto the stack. The previous scene is paused (onExit called), the new scene starts (onEnter called).

      Parameters

      Returns void

    • Render scenes according to renderMode.

      • 'top': renders only the active scene.
      • 'stack': renders all scenes bottom-to-top (paused scenes still visible). Call this from your game loop.

      Returns void

    • Replace the top scene without growing the stack. The old scene is destroyed (onExit called), the new scene starts (onEnter called).

      Parameters

      Returns void

    • Update the active scene. Call this from your game loop. Always delegates to the topmost scene only, regardless of renderMode.

      Parameters

      • dt: number

      Returns void