Skip to main content

@palco-2d/core / SceneHandler

Class: SceneHandler

Defined in: src/SceneHandler/SceneHandler.ts:7

Responsible for scene management, providing the capability to start, pause, and stop scenes, as well as seamlessly switch between them while maintaining a reference to the currently active scene.

Constructors

new SceneHandler()

new SceneHandler(): SceneHandler

Defined in: src/SceneHandler/SceneHandler.ts:30

Returns

SceneHandler

Properties

canvas

static canvas: HTMLCanvasElement

Defined in: src/SceneHandler/SceneHandler.ts:22

The HTML canvas element the scenes render to.


currentScene

static currentScene: Scene

Defined in: src/SceneHandler/SceneHandler.ts:17

Current running scene.


upperCanvas

static upperCanvas: HTMLCanvasElement

Defined in: src/SceneHandler/SceneHandler.ts:28

The HTML canvas element the scenes used by scene plugins. to render on top of the main canvas, without interfering with the main canvas.

Methods

addScene()

addScene(scene, name): void

Defined in: src/SceneHandler/SceneHandler.ts:85

Adds a scene to the handler so later it can be referenced by its name.

Parameters

scene

typeof Scene

name

string

Returns

void


getScene()

getScene(name): Scene

Defined in: src/SceneHandler/SceneHandler.ts:95

Returns the scene with the given name.

Parameters

name

string

The name of the scene to get.

Returns

Scene

The Scene with the given name.


getSceneNames()

getSceneNames(): string[]

Defined in: src/SceneHandler/SceneHandler.ts:128

Get all the scene names added to the handler.

Returns

string[]

An array with all the scene names.


setCurrentScene()

setCurrentScene(name): void

Defined in: src/SceneHandler/SceneHandler.ts:63

Stops the current scene and starts the scene with the given name.

Parameters

name

string

The name of the scene to start.

Returns

void


startScene()

startScene(name): void

Defined in: src/SceneHandler/SceneHandler.ts:103

Starts the scene with the given name.

Parameters

name

string

The name of the scene to start.

Returns

void


stopScene()

stopScene(name): void

Defined in: src/SceneHandler/SceneHandler.ts:116

Stop the scene with the given name.

Parameters

name

string

The name of the scene to stop.

Returns

void


getCurrentScene()

static getCurrentScene(): Scene

Defined in: src/SceneHandler/SceneHandler.ts:78

Returns

Scene