Remarks
A scene is loaded and unloaded throughctx.scenes. Each load creates a
new instance, dropped after its unload: keep what the scene creates
(entities, systems…) in its fields, and remove it in unload.
Scenes form a tree: a scene names the scene it is loaded under with a
static parent. Loading a scene first loads its parents that are not
loaded yet. Only one chain of scenes is loaded at a time, from a root
scene to the current one.
Document a scene for the editor like components and systems: a TSDoc
comment with the @scene tag, @side (client, server or shared)
and @vars (the vars it inits or reads). Its parent is read from
static parent, its params from the type argument.
Example
Extended by
Type Parameters
TParams
TParams = undefined
Shape of the params the scene expects in load.
Constructors
Constructor
new Scene<TParams>():Scene<TParams>
Returns
Scene<TParams>
Properties
parent?
Defined in: modules/scene/src/scene.ts:82 The scene this one is loaded under, if any.readonlystaticoptionalparent?:SceneClass<never>
Remarks
ctx.scenes.load(ctx, Scene, { parent }) loads a scene under another
parent for that load (a pause menu shown on any scene).
Methods
load()
load(Defined in: modules/scene/src/scene.ts:91 Called when the scene is loaded, after its parents._ctx,_scene):void|Promise<void>
Parameters
_ctx
Context
The context given to ctx.scenes.load.
_scene
SceneLoadContext<TParams>
The params of the load.
Returns
void | Promise<void>
unload()
unload(Defined in: modules/scene/src/scene.ts:100 Called when the scene is unloaded, after the scenes loaded under it. The vars it owns are removed right after._ctx):void|Promise<void>
Parameters
_ctx
Context
The context given to ctx.scenes.load or ctx.scenes.unload.
Returns
void | Promise<void>