Skip to content
gabrielsr edited this page Dec 28, 2014 · 3 revisions

You can use GroupManager to group entities in your game. This manager is useful to manage entities that have something in common. An example could be a "MONSTERS" group. When creating an entity you need to register it into the group:

Entity bullet = world.createEntity();
world.getManager(GroupManager.class).add(bullet, "MONSTERS");

You can now retrieve an ImmutableBag of all the entities marked as "MONSTERS" using:

ImmutableBag<Entity> monsters = world.getManager(GroupManager.class).getEntities("MONSTERS");

Every entity can be assigned to multiple groups. By the way, keep in mind that in an entity framework the proper way to process entities through systems is by defining Aspects the system will work on, and this should suffice in most cases: groups should not become a way to substitute Aspects.

Clone this wiki locally