mwg API
    Preparing search index...

    Class SceneAbstract

    One screen of the game: a title, a menu, the dungeon itself.

    This is the lifecycle half only, and owns no renderer: create, update, resize, the suspend/resume pair a pushed scene needs, and a destroy that fires once. two-d.Scene2D adds the Pixi container a 2D game draws into; a Babylon game supplies its own equivalent. The split exists so SceneStack - which never touches a display node, only these methods - works for either, rather than scene management being something only a Pixi game gets.

    Switching scenes destroys the old one, so a scene may hold whatever state it likes without cleaning up by hand.

    import { Scene } from '@datamoc/mw_games/core';

    // a 2D game extends two-d.Scene2D instead, which adds the Pixi display container;
    // this base is what a renderer-free game (or a Babylon one) extends directly.
    class TitleScreen extends Scene {
    create(): void {
    // build the screen's own state here
    }
    }

    Hierarchy (View Summary)

    Index
    onDestroy: Signal<void> = ...

    fires when the scene is torn down, for listeners that need to detach

    • builds the scene's contents; assets are already loaded when this runs

      Returns void

    • Called when the scene above pops, reporting back what it decided.

      Parameters

      • _result: unknown

      Returns void

    • Called when another scene is pushed on top of this one.

      Updating already stops on its own - only the top scene runs - but input listeners do not stand down by themselves. A scene holding windows, music or key handlers pauses or detaches them here; the default does nothing.

      Returns void

    • the display was resized; the scene may relayout rather than be rebuilt

      Parameters

      • _width: number
      • _height: number

      Returns void

    • Renderer-owned resources this scene holds, released exactly once as it is destroyed.

      The base owns none, because it owns no renderer; two-d.Scene2D destroys its container here. A subclass overriding it does not need to call super.teardown().

      Returns void