retro-engine / Exports / Scene
Class representing a scene. A scene is a collection of entities and systems.
- addEntity
- addSystem
- deleteEntity
- getEntities
- getEntitiesWithComponent
- getEntity
- getSystems
- hasSystem
- removeSystem
- renameEntity
- spawnPrefab
Name | Type |
---|---|
name |
string |
The name of the scene.
• name: string
Add an entity to the scene.
▸ addEntity<T
>(entity
, args?
): void
Name | Type |
---|---|
T |
extends GameObjectBase <T > |
Name | Type | Default value |
---|---|---|
entity |
T |
undefined |
args |
any [] |
[] |
void
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
Name | Type |
---|---|
system |
System |
priority |
number |
void
Delete an entity from the scene.
▸ deleteEntity(entity
): void
Name | Type |
---|---|
entity |
GameObjectBase |
void
Delete an entity from the scene.
▸ deleteEntityByName(name
): void
Name | Type |
---|---|
name |
string |
void
Get a map of all entities in the scene.
▸ getEntities(): Map
<string
, GameObjectBase
>
Map
<string
, GameObjectBase
>
Get a list of all entities with a specific component.
▸ getEntitiesWithComponent<T
>(component
): GameObjectBase
[]
Name | Type |
---|---|
T |
extends Component <T > |
Name | Type |
---|---|
component |
ComponentType <T > |
Get an entity by name.
▸ getEntity(name
): GameObjectBase
Name | Type |
---|---|
name |
string |
Get a list of all systems in the scene.
▸ getSystems(): SystemNode
[]
Check if a system is in the scene.
▸ hasSystem(system_name
): boolean
Name | Type |
---|---|
system_name |
string |
boolean
Remove a system from the scene.
▸ removeSystem(system
): void
Name | Type |
---|---|
system |
System |
void
Rename an entity in the scene.
▸ renameEntity(old_name
, new_name
): void
Name | Type |
---|---|
old_name |
string |
new_name |
string |
void
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
Name | Type |
---|---|
prefab_name |
string |
args |
any [] |
name |
string |
void