Skip to content
Shaun Reich edited this page Nov 28, 2015 · 3 revisions

You can use the TagManager to manage entities that, because of their nature, can be labeled with a particular, unique tag (usually a string). A classical example could be the “player” tag: the player is, in many cases, only one, and it could be necessary to retrieve the corresponding entity into systems. TagManager helps you doing this easily. When the entity is created, you have to register it to the TagManager:

Entity e = world.createEntity();
world.getSystem(TagManager.class).register("PLAYER", e);

You can now access the player entity anywhere:

Entity player = world.getSystem(TagManager.class).getEntity("PLAYER");

Note that it used to be .getManager, but this method is deprecated since managers and systems have been coalesced.

It is also possible to unregister the entity from the TagManager:

world.getManager(TagManager.class).unregister("PLAYER");
Clone this wiki locally