new EntityContainer()
This component allows the entity to contain child entities. It will add several methods to the entity to manage adding and removing entities.
- Source:
Listens to Events:
- platypus.Entity#event:add-entity
- platypus.Entity#event:child-entity-updated
- platypus.Entity#event:handle-logic
- platypus.Entity#event:remove-entity
Extends
Methods
addEntity(newEntity, callbackopt) → {platypus.Entity}
This method adds an entity to the owner's group. If an entity definition or a reference to an entity definition is provided, the entity is created and then added to the owner's group.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
newEntity |
platypus.Entity
|
Object
|
String
|
Specifies the entity to add. If an object with a "type" property is provided or a String is provided, this component looks up the entity definition to create the entity.
|
|||||||||||||
callback |
function
|
<optional> |
A function to run once all of the components on the Entity have been loaded. |
Fires:
getEntitiesByType(type) → {Array}
Returns a list of entities of the requested type.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String
|
Returns:
- Type:
-
Array
getEntityById(id) → {Entity}
Gets an entity in this layer by its Id. Returns null if not found.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String
|
Returns:
- Type:
-
Entity
removeEntity(entity) → {Entity}
Removes the provided entity from the layer and destroys it. Returns false if the entity is not found in the layer.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
entity |
Entity
|
Fires:
Returns:
- Type:
-
Entity
triggerEventOnChildren(event, message, debug)
Triggers a single event on the child entities in the layer.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
*
|
|
message |
*
|
|
debug |
*
|
triggerOnChildren(event, message, debug)
Triggers one or more events on the child entities in the layer. This is unique from triggerEventOnChildren in that it also accepts an Array to send multiple events.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
*
|
|
message |
*
|
|
debug |
*
|