melonJS
    Preparing search index...

    Class Stage

    a default "Stage" object. every "stage" object (title screen, credits, ingame, etc...) to be managed through the state manager must inherit from this base class.

    state

    Index

    Constructors

    • Parameters

      • Optionalsettings: Partial<StageSettings>

        The stage parameters

        • cameras

          a list of cameras (experimental)

        • onResetEvent

          called by the state manager when reseting the object

        • onDestroyEvent

          called by the state manager before switching to another state

      Returns Stage

    Properties

    ambientLight: Color

    an ambient light that will be added to the stage rendering

    "#000000"
    

    Light2d

    cameras: Map<string, Camera2d>

    The list of active cameras in this stage. Cameras will be rendered based on this order defined in this list. Only the "default" camera will be resized when the window or canvas is resized.

    lights: Map<string, Light2d>

    The list of active lights in this stage. (Note: Canvas Rendering mode will only properly support one light per stage)

    • Light2d
    • Stage.ambientLight
    // create a white spot light
    const whiteLight = new Light2d(0, 0, 140, "#fff", 0.7);
    // and add the light to this current stage
    this.lights.set("whiteLight", whiteLight);
    // set a dark ambient light
    this.ambientLight.parseCSS("#1117");
    // make the light follow the mouse
    input.registerPointerEvent("pointermove", app.viewport, (event) => {
    whiteLight.centerOn(event.gameX, event.gameY);
    });
    settings: StageSettings

    The given constructor options

    Methods

    • onResetEvent function
      called by the state manager when resetting the object this is typically where you will load a level, add renderables, etc...

      Parameters

      • app: Application

        the current application instance

      • ...args: unknown[]

        optional arguments passed when switching state

      Returns void

      state#change