Entity.add

Add a component to the entity.

If a component of the same type is already attached, it will be removed and replaced by the supplied component.

  1. Entity add(T component)
    class Entity
    add
    (
    T
    )
  2. Entity add(Object component, ClassInfo class_info)

Parameters

T

the type of component it is to be stored as

Return Value

Type: Entity

A reference to the entity. This enables the chaining of calls to add, to make creating and configuring entities cleaner. e.g.

Entity entity = new Entity() entity.add( new Position( 100, 200 ) ) entity.add( new Display( new PlayerClip() ) );

Meta