Stage

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.

See: state

Constructor


new Stage(settings: object) → {}
Parameters:
Name Type Attributes Default Description
settings object

<optional>

The stage` parameters

settings.cameras Array<Camera2d>

<optional>

[new me.Camera2d()]

a list of cameras (experimental)

settings.onResetEvent Function

<optional>

called by the state manager when reseting the object

settings.onDestroyEvent Function

<optional>

called by the state manager before switching to another state

Summary


Properties from Stage

Public Properties


ambientLight stage.js:64
ambientLight: Color = "#000000"

Color

an ambient light that will be added to the stage rendering

See: Light2d
cameras stage.js:30
cameras: Map<Camera2d>

Map<Camera2d>

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

lights stage.js:41
lights: Map<Light2d>

Map<Light2d>

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

// create a white spot light
let whiteLight = new me.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
me.input.registerPointerEvent("pointermove", me.game.viewport, (event) => {
   whiteLight.centerOn(event.gameX, event.gameY);
});
See:
settings stage.js:75
settings: object

object

The given constructor options

Public Methods


onDestroyEvent stage.js:214
onDestroyEvent() → {}

onDestroyEvent function
called by the state manager before switching to another state

onResetEvent stage.js:198
onResetEvent(args: unknown) → {}

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

Parameters:
Name Type Attributes Description
args unknown

<optional>

optional arguments passed when switching state

See: state#change

Powered by webdoc!