Scene
Defined in: Scene.ts:26
Scenes own entities and define lifecycle hooks. Each scene is a self-contained world with its own entity pool.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Scene():
Scene
Returns
Section titled “Returns”Scene
Properties
Section titled “Properties”
abstractreadonlyname:string
Defined in: Scene.ts:28
Name for debugging/inspection.
pauseBelow
Section titled “pauseBelow”
readonlypauseBelow:boolean=true
Defined in: Scene.ts:31
Whether scenes below this one in the stack should be paused. Default: true.
paused
Section titled “paused”paused:
boolean=false
Defined in: Scene.ts:40
Manual pause flag. Set by game code to pause this scene regardless of stack position.
preload?
Section titled “preload?”
readonlyoptionalpreload?: readonlyAssetHandle<unknown>[]
Defined in: Scene.ts:37
Asset handles to load before onEnter(). Override in subclasses.
timeScale
Section titled “timeScale”timeScale:
number=1
Defined in: Scene.ts:43
Time scale multiplier for this scene. 1.0 = normal, 0.5 = half speed. Default: 1.
transparentBelow
Section titled “transparentBelow”
readonlytransparentBelow:boolean=false
Defined in: Scene.ts:34
Whether scenes below this one should still render. Default: false.
Accessors
Section titled “Accessors”assets
Section titled “assets”Get Signature
Section titled “Get Signature”get assets():
AssetManager
Defined in: Scene.ts:76
Convenience accessor for the AssetManager.
Returns
Section titled “Returns”context
Section titled “context”Get Signature
Section titled “Get Signature”get context():
EngineContext
Defined in: Scene.ts:57
Access the EngineContext.
Returns
Section titled “Returns”isPaused
Section titled “isPaused”Get Signature
Section titled “Get Signature”get isPaused():
boolean
Defined in: Scene.ts:62
Whether this scene is effectively paused (manual pause or paused by stack).
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”_addExistingEntity()
Section titled “_addExistingEntity()”_addExistingEntity(
entity):void
Defined in: Scene.ts:155
Internal
Add an existing entity to this scene (used by Entity.addChild for auto-scene-membership).
Parameters
Section titled “Parameters”entity
Section titled “entity”Returns
Section titled “Returns”void
_destroyAllEntities()
Section titled “_destroyAllEntities()”_destroyAllEntities():
void
Defined in: Scene.ts:318
Internal
Destroy all entities — used during scene exit.
Returns
Section titled “Returns”void
_flushDestroyQueue()
Section titled “_flushDestroyQueue()”_flushDestroyQueue():
void
Defined in: Scene.ts:304
Internal
Flush the destroy queue — destroy pending entities. Called by the engine during the endOfFrame phase.
Returns
Section titled “Returns”void
_onEntityEvent()
Section titled “_onEntityEvent()”_onEntityEvent(
eventName,data,entity):void
Defined in: Scene.ts:237
Internal
Called by Entity.emit() for bubbling entity events to the scene.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
unknown
entity
Section titled “entity”Returns
Section titled “Returns”void
_queueDestroy()
Section titled “_queueDestroy()”_queueDestroy(
entity):void
Defined in: Scene.ts:175
Internal
Add an entity to the destroy queue. Called by Entity.destroy().
Parameters
Section titled “Parameters”entity
Section titled “entity”Returns
Section titled “Returns”void
_setContext()
Section titled “_setContext()”_setContext(
context):void
Defined in: Scene.ts:275
Internal
Set the engine context. Called by SceneManager when the scene is pushed.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”void
afterRestore()?
Section titled “afterRestore()?”
optionalafterRestore(data,resolve):void
Defined in: Scene.ts:267
Called after entities are restored during save/load. Rebuild non-serializable state here.
Parameters
Section titled “Parameters”unknown
resolve
Section titled “resolve”Returns
Section titled “Returns”void
destroyEntity()
Section titled “destroyEntity()”destroyEntity(
entity):void
Defined in: Scene.ts:167
Mark an entity for destruction. Deferred to endOfFrame flush.
Parameters
Section titled “Parameters”entity
Section titled “entity”Returns
Section titled “Returns”void
findEntities()
Section titled “findEntities()”Call Signature
Section titled “Call Signature”findEntities<
T>(filter):Entity&T[]
Defined in: Scene.ts:202
Find entities matching a filter. Trait filter narrows the return type.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”filter
Section titled “filter”EntityFilter & object
Returns
Section titled “Returns”Entity & T[]
Call Signature
Section titled “Call Signature”findEntities(
filter?):Entity[]
Defined in: Scene.ts:203
Find entities matching a filter. Trait filter narrows the return type.
Parameters
Section titled “Parameters”filter?
Section titled “filter?”Returns
Section titled “Returns”Entity[]
findEntitiesByTag()
Section titled “findEntitiesByTag()”findEntitiesByTag(
tag):Entity[]
Defined in: Scene.ts:193
Find entities by tag.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Entity[]
findEntity()
Section titled “findEntity()”findEntity(
name):Entity|undefined
Defined in: Scene.ts:185
Find entity by name (first match).
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Entity | undefined
getEntities()
Section titled “getEntities()”getEntities():
ReadonlySet<Entity>
Defined in: Scene.ts:180
Get all active entities.
Returns
Section titled “Returns”ReadonlySet<Entity>
on<
T>(token,handler): () =>void
Defined in: Scene.ts:216
Subscribe to bubbled entity events at the scene level. Handler receives (data, emittingEntity).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”EventToken<T>
handler
Section titled “handler”(data, entity) => void
Returns
Section titled “Returns”() => void
onEnter()?
Section titled “onEnter()?”
optionalonEnter():void
Defined in: Scene.ts:252
Called when the scene is entered (after preload completes).
Returns
Section titled “Returns”void
onExit()?
Section titled “onExit()?”
optionalonExit():void
Defined in: Scene.ts:255
Called when the scene is exited (popped or replaced).
Returns
Section titled “Returns”void
onPause()?
Section titled “onPause()?”
optionalonPause():void
Defined in: Scene.ts:258
Called when a scene is pushed on top of this one.
Returns
Section titled “Returns”void
onProgress()?
Section titled “onProgress()?”
optionalonProgress(ratio):void
Defined in: Scene.ts:249
Called during asset preloading with progress ratio (0→1).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
onResume()?
Section titled “onResume()?”
optionalonResume():void
Defined in: Scene.ts:261
Called when the scene above is popped, restoring this scene.
Returns
Section titled “Returns”void
serialize()?
Section titled “serialize()?”
optionalserialize():unknown
Defined in: Scene.ts:264
Return a JSON-serializable snapshot of this scene’s custom state. Used by the save system.
Returns
Section titled “Returns”unknown
service()
Section titled “service()”
protectedservice<T>(key):T
Defined in: Scene.ts:87
Lazy proxy-based service resolution. Can be used at field-declaration time:
readonly layers = this.service(RenderLayerManagerKey);The actual resolution is deferred until first property access.
Type Parameters
Section titled “Type Parameters”T extends object
Parameters
Section titled “Parameters”ServiceKey<T>
Returns
Section titled “Returns”T
spawn()
Section titled “spawn()”Call Signature
Section titled “Call Signature”spawn(
name?):Entity
Defined in: Scene.ts:106
Spawn a new entity in this scene.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”spawn<
P>(blueprint,params):Entity
Defined in: Scene.ts:107
Spawn a new entity in this scene.
Type Parameters
Section titled “Type Parameters”P
Parameters
Section titled “Parameters”blueprint
Section titled “blueprint”Blueprint<P>
params
Section titled “params”P
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”spawn(
blueprint):Entity
Defined in: Scene.ts:108
Spawn a new entity in this scene.
Parameters
Section titled “Parameters”blueprint
Section titled “blueprint”Blueprint<void>
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”spawn<
E,P>(Class,params):E
Defined in: Scene.ts:110
Spawn an entity subclass with setup params.
Type Parameters
Section titled “Type Parameters”E extends Entity
P
Parameters
Section titled “Parameters”() => E & object
params
Section titled “params”P
Returns
Section titled “Returns”E
Call Signature
Section titled “Call Signature”spawn<
E>(Class):E
Defined in: Scene.ts:115
Spawn an entity subclass without setup params.
Type Parameters
Section titled “Type Parameters”E extends Entity
Parameters
Section titled “Parameters”() => E
Returns
Section titled “Returns”E