Skip to content
Avetis edited this page Nov 9, 2015 · 1 revision

When you have a hierarchy of nested items, you need a nice reliable way to navigate through children. At this moment There are several ways you can do it.

Navigating through nested entities.

When an engine with Entities is created by scene loader, you can retrieve the root entity by calling sl.getRoot(); This entity is a Composite Item, meaning it has other entities in it, that means you should be able to navigate through this starting from the root item. Because Entity by itself is an empty container that can have no methods for us, we made a helper class called ItemWrapper to help you do that. ItemWrapper wraps around Entity (meaning it receives it in constructor) and then gives plethora of methods to work with it, or search in it.

Getting Child by ID If an item you are looking for is inside the root entity, and has id "foo", here is how you can navigate to it.

ItemWrapper root = new ItemWrapper(sl.getRoot());
Entity foo = root.getChild("foo").getEntity();

You can also do more complex things like:

ItemWrapper root = new ItemWrapper(sl.getRoot());
Entity foo = root.getChild("foo").getChild("bar").getEntity();

Navigating through nested CompositeActors

Coming Soon