Entity

entity~ Entity

The entity class expose methods to associate the entity to components and to get/set components data.
To create a new entity, use the Engine.entity() method.

Constructor

(private) new Entity(name)

Source:

Do not instantiate this class directly, use the Engine.entity() method.

Parameters:
Name Type Description
name String

Entity name

Extends

  • EventEmitter

Methods

deleteComponent(componentName)

Source:

Remove a component association

Parameters:
Name Type Description
componentName String

destroy()

Source:

Remove this entity from the engine

getComponent(componentName)

Source:

Retrieve a component by name

Parameters:
Name Type Description
componentName String

The component name

getName() → {String}

Source:

Returns this entity name

Returns:

this entity name

Type
String

hasComponent(componentName) → {Boolean}

Source:

Check if the entity is associated to a component

Parameters:
Name Type Description
componentName String

Name of the component

Returns:

true if the entity has the component associated, false otherwise.

Type
Boolean

setComponent(componentName, componentData)

Source:

Associate the entity to a component. The component can be any type.

Parameters:
Name Type Description
componentName String

The component name

componentData *

The component data