Skip to content
Daan van Yperen edited this page Jul 29, 2014 · 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.getManager(TagManager.class).register("PLAYER", e);

You can now access the player entity anywhere:

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

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

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