Skip to content
Daan van Yperen edited this page Aug 11, 2015 · 50 revisions

Entities are distinct containers of related components.

Creating

Builder

 Entity myEntity = new EntityBuilder(world)
 .with(new Pos(10,10), new Anim("Chicken"))
 .tag("boss")
 .group("enemies")
 .build();

Manual

    Entity chicken = world.createEntity();
    EntityEdit chickenEdit = chicken.edit();
    chickenEdit.add(new Pos(10,10));
    chickenEdit.add(Anim.class).name = "Chicken;

Advanced

  • Archetype - Fastest, low level, no parameterized components.
  • Entity Factory - Fast, clean and convenient. For fixed composition entities. Requires some setup.

Editing

by class

  EntityEdit chickenEdit = entity.edit();
  Flaming flaming = chickenEdit.create(Flaming.class);
  flaming.strength = 500;
  chickenEdit.remove(Freezing.class);

Entity Transmuters allow for high performance edits.

by instance

entity.edit().add(new Flaming(500))

Discouraged for games that may require pooling or packing!

Clone this wiki locally