setup, and removed when it is unloaded.
Remarks
Writesetup like an app’s main: const x = registry.spawnEntity(),
registry.addComponent(x, new C(...)), registry.addSystem(fn). The registry it gets is the
app’s, tracked: when the scene is unloaded, the systems added through it are removed, and the
entities spawned through it are killed. A component with a destroy() method gets it called
first (a component holding a graphics shape removes it from the screen).
The editor edits setup the way it edits main (spawns written out, one per variable).
Example
Extends
Scene<TParams>
Type Parameters
TParams
TParams = undefined
Shape of the params the scene expects.
Constructors
Constructor
new EcsScene<TParams>():EcsScene<TParams>
Returns
EcsScene<TParams>
Inherited from
Scene.constructor
Properties
parent?
Defined in: modules/scene/dist/index.d.ts:81 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).
Inherited from
Scene.parent
Methods
load()
load(Defined in: modules/ecs/src/scene/ecs-scene.ts:69 Called when the scene is loaded, after its parents.ctx,scene):Promise<void>
Parameters
ctx
Context
The context given to ctx.scenes.load.
scene
SceneLoadContext<TParams>
The params of the load.
Returns
Promise<void>
Overrides
Scene.load
setup()
setup(Defined in: modules/ecs/src/scene/ecs-scene.ts:53 Makes the scene’s entities and systems._registry,_ctx,_scene):void|Promise<void>
Parameters
_registry
Registry
The app’s registry, tracked for this scene.
_ctx
Context
The context given to ctx.scenes.load.
_scene
SceneLoadContext<TParams>
The scene’s id and params.
Returns
void | Promise<void>
teardown()
teardown(Defined in: modules/ecs/src/scene/ecs-scene.ts:67 Called when the scene is unloaded, before its entities and systems are removed._registry,_ctx):void|Promise<void>
Parameters
_registry
Registry
The app’s registry.
_ctx
Context
The context given to ctx.scenes.load or ctx.scenes.unload.
Returns
void | Promise<void>
unload()
unload(Defined in: modules/ecs/src/scene/ecs-scene.ts:73 Called when the scene is unloaded, after the scenes loaded under it. The vars it owns are removed right after.ctx):Promise<void>
Parameters
ctx
Context
The context given to ctx.scenes.load or ctx.scenes.unload.
Returns
Promise<void>
Overrides
Scene.unload