Skip to content

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.

new Scene(): Scene

Scene

abstract readonly name: string

Defined in: Scene.ts:28

Name for debugging/inspection.


readonly pauseBelow: boolean = true

Defined in: Scene.ts:31

Whether scenes below this one in the stack should be paused. Default: true.


paused: boolean = false

Defined in: Scene.ts:40

Manual pause flag. Set by game code to pause this scene regardless of stack position.


readonly optional preload?: readonly AssetHandle<unknown>[]

Defined in: Scene.ts:37

Asset handles to load before onEnter(). Override in subclasses.


timeScale: number = 1

Defined in: Scene.ts:43

Time scale multiplier for this scene. 1.0 = normal, 0.5 = half speed. Default: 1.


readonly transparentBelow: boolean = false

Defined in: Scene.ts:34

Whether scenes below this one should still render. Default: false.

get assets(): AssetManager

Defined in: Scene.ts:76

Convenience accessor for the AssetManager.

AssetManager


get context(): EngineContext

Defined in: Scene.ts:57

Access the EngineContext.

EngineContext


get isPaused(): boolean

Defined in: Scene.ts:62

Whether this scene is effectively paused (manual pause or paused by stack).

boolean

_addExistingEntity(entity): void

Defined in: Scene.ts:155

Internal

Add an existing entity to this scene (used by Entity.addChild for auto-scene-membership).

Entity

void


_destroyAllEntities(): void

Defined in: Scene.ts:318

Internal

Destroy all entities — used during scene exit.

void


_flushDestroyQueue(): void

Defined in: Scene.ts:304

Internal

Flush the destroy queue — destroy pending entities. Called by the engine during the endOfFrame phase.

void


_onEntityEvent(eventName, data, entity): void

Defined in: Scene.ts:237

Internal

Called by Entity.emit() for bubbling entity events to the scene.

string

unknown

Entity

void


_queueDestroy(entity): void

Defined in: Scene.ts:175

Internal

Add an entity to the destroy queue. Called by Entity.destroy().

Entity

void


_setContext(context): void

Defined in: Scene.ts:275

Internal

Set the engine context. Called by SceneManager when the scene is pushed.

EngineContext

void


optional afterRestore(data, resolve): void

Defined in: Scene.ts:267

Called after entities are restored during save/load. Rebuild non-serializable state here.

unknown

SnapshotResolver

void


destroyEntity(entity): void

Defined in: Scene.ts:167

Mark an entity for destruction. Deferred to endOfFrame flush.

Entity

void


findEntities<T>(filter): Entity & T[]

Defined in: Scene.ts:202

Find entities matching a filter. Trait filter narrows the return type.

T

EntityFilter & object

Entity & T[]

findEntities(filter?): Entity[]

Defined in: Scene.ts:203

Find entities matching a filter. Trait filter narrows the return type.

EntityFilter

Entity[]


findEntitiesByTag(tag): Entity[]

Defined in: Scene.ts:193

Find entities by tag.

string

Entity[]


findEntity(name): Entity | undefined

Defined in: Scene.ts:185

Find entity by name (first match).

string

Entity | undefined


getEntities(): ReadonlySet<Entity>

Defined in: Scene.ts:180

Get all active entities.

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).

T

EventToken<T>

(data, entity) => void

() => void


optional onEnter(): void

Defined in: Scene.ts:252

Called when the scene is entered (after preload completes).

void


optional onExit(): void

Defined in: Scene.ts:255

Called when the scene is exited (popped or replaced).

void


optional onPause(): void

Defined in: Scene.ts:258

Called when a scene is pushed on top of this one.

void


optional onProgress(ratio): void

Defined in: Scene.ts:249

Called during asset preloading with progress ratio (0→1).

number

void


optional onResume(): void

Defined in: Scene.ts:261

Called when the scene above is popped, restoring this scene.

void


optional serialize(): unknown

Defined in: Scene.ts:264

Return a JSON-serializable snapshot of this scene’s custom state. Used by the save system.

unknown


protected service<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.

T extends object

ServiceKey<T>

T


spawn(name?): Entity

Defined in: Scene.ts:106

Spawn a new entity in this scene.

string

Entity

spawn<P>(blueprint, params): Entity

Defined in: Scene.ts:107

Spawn a new entity in this scene.

P

Blueprint<P>

P

Entity

spawn(blueprint): Entity

Defined in: Scene.ts:108

Spawn a new entity in this scene.

Blueprint<void>

Entity

spawn<E, P>(Class, params): E

Defined in: Scene.ts:110

Spawn an entity subclass with setup params.

E extends Entity

P

() => E & object

P

E

spawn<E>(Class): E

Defined in: Scene.ts:115

Spawn an entity subclass without setup params.

E extends Entity

() => E

E