Skip to content

SpawnBatch

Defined in: SpawnBatch.ts:16

The operations available inside a Scene.spawnBatch callback.

Reserve every entity first, link the hierarchy, then run setup. Because all of them exist before any setup() runs, a setup parameter can hold a handle to an entity that has not been set up yet.

addChild(parent, name, child): void

Defined in: SpawnBatch.ts:34

Link two reserved entities, so the child’s setup() can read its parent and siblings. Both must come from this batch’s reserve().

Entity

string

Entity

void


reserve<E>(Class, options?): E

Defined in: SpawnBatch.ts:28

Construct an entity and register its key without running setup(). The entity belongs to the scene from this point — entity.scene, entity.handle(), and entity.requireKey() all work — but it stays out of scene.getEntities(), findByKey(), and every query until the batch commits.

options.active sets the state the entity wakes up in. The default, true, activates it when the batch commits; false commits it dormant, to be woken later with setActive(true).

E extends Entity

() => E

SpawnOptions

E


setup<E>(entity, …rest): void

Defined in: SpawnBatch.ts:40

Run a reserved entity’s setup(). Trailing arguments follow its setup signature, the way scene.spawn(Class, params) does.

E extends Entity

E

…SetupArgs<E>

void