Skip to content

Latest commit

 

History

History
304 lines (181 loc) · 5.82 KB

Scene.md

File metadata and controls

304 lines (181 loc) · 5.82 KB

retro-engine / Exports / Scene

Class: Scene

Class representing a scene. A scene is a collection of entities and systems.

Table of contents

Properties

Methods

Parameters

Name Type
name string

Defined in

src/scene.ts:22

Properties

name

The name of the scene.

name: string

Defined in

src/scene.ts:20

Methods

addEntity

Add an entity to the scene.

addEntity<T>(entity, args?): void

Type parameters

Name Type
T extends GameObjectBase<T>

Parameters

Name Type Default value
entity T undefined
args any[] []

Returns

void

Defined in

src/scene.ts:55


addSystem

Manually add a system to the scene. The priority determines the order in which systems are updated. Systems with a higher priority are updated first. Systems with the same priority are updated in the order they were added.

Generally, systems are added automatically when an entity with the required components is added to the scene.

addSystem(system, priority): void

Parameters

Name Type
system System
priority number

Returns

void

Defined in

src/scene.ts:147


deleteEntity

Delete an entity from the scene.

deleteEntity(entity): void

Parameters

Name Type
entity GameObjectBase

Returns

void

Defined in

src/scene.ts:111



deleteEntityByName

Delete an entity from the scene.

deleteEntityByName(name): void

Parameters

Name Type
name string

Returns

void

Defined in

src/scene.ts:102


getEntities

Get a map of all entities in the scene.

getEntities(): Map<string, GameObjectBase>

Returns

Map<string, GameObjectBase>

Defined in

src/scene.ts:42


getEntitiesWithComponent

Get a list of all entities with a specific component.

getEntitiesWithComponent<T>(component): GameObjectBase[]

Type parameters

Name Type
T extends Component<T>

Parameters

Name Type
component ComponentType<T>

Returns

GameObjectBase[]

Defined in

src/scene.ts:139


getEntity

Get an entity by name.

getEntity(name): GameObjectBase

Parameters

Name Type
name string

Returns

GameObjectBase

Defined in

src/scene.ts:89


getSystems

Get a list of all systems in the scene.

getSystems(): SystemNode[]

Returns

SystemNode[]

Defined in

src/scene.ts:46


hasSystem

Check if a system is in the scene.

hasSystem(system_name): boolean

Parameters

Name Type
system_name string

Returns

boolean

Defined in

src/scene.ts:50


removeSystem

Remove a system from the scene.

removeSystem(system): void

Parameters

Name Type
system System

Returns

void

Defined in

src/scene.ts:163


renameEntity

Rename an entity in the scene.

renameEntity(old_name, new_name): void

Parameters

Name Type
old_name string
new_name string

Returns

void

Defined in

src/scene.ts:129


spawnPrefab

Spawn a prefab in the scene. The optional name parameter can be used to give the spawned entity a custom name, which can be used to access the entity by name through the Scene it is in.

spawnPrefab(prefab_name, args, name?): void

Parameters

Name Type
prefab_name string
args any[]
name string

Returns

void

Defined in

src/scene.ts:81