namesToActors.put(actor.name, actor);\r
actor.parent = this;\r
}\r
+ \r
+ /**\r
+ * Adds an {@link Actor} at the given index in the group. The first Actor added will be at\r
+ * index 0 and so on. Throws an IndexOutOfBoundsException in case the index is invalid.\r
+ * @param index the index to add the actor at.\r
+ */\r
+ public void addActorAt(int index, Actor actor) {\r
+ children.add(index, actor);\r
+ if(actor instanceof Group)groups.add((Group)actor);\r
+ namesToActors.put(actor.name, actor);\r
+ actor.parent = this; \r
+ }\r
+ \r
+ /**\r
+ * Adds an {@link Actor} before the given Actor. \r
+ * @param actorBefore the Actor to add the other actor in front of\r
+ * @param actor the Actor to add\r
+ */\r
+ public void addActorBefore(Actor actorBefore, Actor actor) {\r
+ int index = children.indexOf(actorBefore); \r
+ children.add(index, actor);\r
+ if(actor instanceof Group)groups.add((Group)actor);\r
+ namesToActors.put(actor.name, actor);\r
+ actor.parent = this; \r
+ }\r
\r
/**\r
+ * Adds an {@link Actor} after the given Actor. \r
+ * @param actorAfter the Actor to add the other Actor behind\r
+ * @param actor the Actor to add\r
+ */\r
+ public void addActorAfter(Actor actorAfter, Actor actor) {\r
+ int index = children.indexOf(actorAfter);\r
+ if(index == children.size()) \r
+ children.add(actor);\r
+ else\r
+ children.add(index+1, actor);\r
+ if(actor instanceof Group)groups.add((Group)actor);\r
+ namesToActors.put(actor.name, actor);\r
+ actor.parent = this; \r
+ }\r
+ \r
+ /**\r
* Removes an {@link Actor} from this Group.\r
* @param actor\r
*/\r