Skip to content

Iterating

Mark Knol edited this page Oct 18, 2017 · 3 revisions

Iterating over the hierarchy

You can use the parent, firstChild, next and firstComponent fields to iterate over the hierarchy.

Loop through components

var component = entity.firstComponent;
while (child != null) 
{
	var next = component.next; 
	
	// do something with child here
	doSomethingWith(component);
	
	component = next;
}

Loop through child entities

var child = entity.firstChild;
while (child != null) 
{
	var next = child.next; 
	
	// do something with child here
	doSomethingWith(child);
	
	child = next;
}

As you may noticed, Flambe uses a linked-list to define the hierarchy.

Clone this wiki locally