libgdx API

com.badlogic.gdx.scenes.scene2d
Class Group

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.Group
Direct Known Subclasses:
FlickScrollPane, ScrollPane, SplitPane, Stack, Table

public class Group
extends Actor

A group is an Actor that contains other Actors (also other Groups which are Actors).

Author:
mzechner, Nathan Sweet

Field Summary
protected  Matrix4 batchTransform
           
protected  java.util.List<Actor> children
           
static boolean debug
           
static Texture debugTexture
           
 Actor[] focusedActor
           
protected  java.util.List<Group> groups
           
protected  java.util.List<Actor> immutableChildren
           
protected  java.util.List<Group> immutableGroups
           
 Actor keyboardFocusedActor
           
 Actor lastTouchedChild
           
protected  Matrix3 localTransform
           
protected  ObjectMap<java.lang.String,Actor> namesToActors
           
protected  Matrix4 oldBatchTransform
           
protected  Vector2 point
           
 Actor scrollFocusedActor
           
 boolean transform
           
protected  Matrix3 worldTransform
           
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, touchable, visible, width, x, y
 
Constructor Summary
Group()
           
Group(java.lang.String name)
          Creates a new Group with the given name.
 
Method Summary
 void act(float delta)
           
 void addActor(Actor actor)
          Adds an Actor to this Group.
 void addActorAfter(Actor actorAfter, Actor actor)
          Adds an Actor after the given Actor.
 void addActorAt(int index, Actor actor)
          Adds an Actor at the given index in the group.
 void addActorBefore(Actor actorBefore, Actor actor)
          Adds an Actor before the given Actor.
protected  void applyTransform(SpriteBatch batch)
           
 void clear()
          Clears this Group, removing all contained Actors.
static void disableDebugging()
           
 void draw(SpriteBatch batch, float parentAlpha)
          Draws the Actor.
protected  void drawChild(Actor child, SpriteBatch batch, float parentAlpha)
           
protected  void drawChildren(SpriteBatch batch, float parentAlpha)
           
static void enableDebugging(java.lang.String debugTextureFile)
           
 Actor findActor(java.lang.String name)
          Finds the Actor with the given name in this Group and its children.
 void focus(Actor actor, int pointer)
          Sets the focus to the given child Actor.
 java.util.List<Actor> getActors()
           
 java.util.List<Group> getGroups()
           
 Actor hit(float x, float y)
           
 void keyboardFocus(Actor actor)
          Sets the keyboard focus to the given child Actor.
 boolean keyDown(int keycode)
           
 boolean keyTyped(char character)
           
 boolean keyUp(int keycode)
           
 void removeActor(Actor actor)
          Removes an Actor from this Group.
 void removeActorRecursive(Actor actor)
          Removes an Actor from this Group recursively by checking if the Actor is in this group or one of its child-groups.
protected  void resetTransform(SpriteBatch batch)
           
 boolean scrolled(int amount)
           
 void scrollFocus(Actor actor)
          Sets the scroll focus to the given child Actor.
 void sortChildren(java.util.Comparator<Actor> comparator)
          Sorts the children via the given Comparator.
 boolean swapActor(Actor first, Actor second)
          Swap two actors' sort order by reference.
 boolean swapActor(int first, int second)
          Swap two actors' sort order by index.
static void toChildCoordinates(Actor child, float x, float y, Vector2 out)
          Transforms the coordinates given in the child's parent coordinate system to the child Actor's coordinate system.
 boolean touchDown(float x, float y, int pointer)
           
 void touchDragged(float x, float y, int pointer)
           
 boolean touchMoved(float x, float y)
           
 void touchUp(float x, float y, int pointer)
           
 void unfocusAll()
          Unfocuses all Actor instance currently focused for touch and keyboard events.
 void unfocusAll(Actor actor)
          Unfocuses this Actor from the touch, keyboard and scroll focus from this group and all groups above it.
protected  Matrix4 updateTransform()
           
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
action, clearActions, isMarkedToRemove, markToRemove, remove, toLocalCoordinates, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debugTexture

public static Texture debugTexture

debug

public static boolean debug

children

protected final java.util.List<Actor> children

immutableChildren

protected final java.util.List<Actor> immutableChildren

groups

protected final java.util.List<Group> groups

immutableGroups

protected final java.util.List<Group> immutableGroups

namesToActors

protected final ObjectMap<java.lang.String,Actor> namesToActors

localTransform

protected final Matrix3 localTransform

worldTransform

protected final Matrix3 worldTransform

batchTransform

protected final Matrix4 batchTransform

oldBatchTransform

protected final Matrix4 oldBatchTransform

transform

public boolean transform

lastTouchedChild

public Actor lastTouchedChild

focusedActor

public Actor[] focusedActor

keyboardFocusedActor

public Actor keyboardFocusedActor

scrollFocusedActor

public Actor scrollFocusedActor

point

protected final Vector2 point
Constructor Detail

Group

public Group()

Group

public Group(java.lang.String name)
Creates a new Group with the given name.

Parameters:
name - the name of the group
Method Detail

act

public void act(float delta)
Overrides:
act in class Actor

draw

public void draw(SpriteBatch batch,
                 float parentAlpha)
Description copied from class: Actor
Draws the Actor. The spriteBatch is configured so that the Actor can draw in its parents coordinate system. The parent's alpha is passed to the method in order for the Actor to multiply it with its own alpha. This will allow FadeIn and other Actions to have an effect even if they are only set on the parent of the Actor.

Specified by:
draw in class Actor
Parameters:
batch - the spritebatch to render with
parentAlpha - the parent's alpha value.

drawChildren

protected void drawChildren(SpriteBatch batch,
                            float parentAlpha)

drawChild

protected void drawChild(Actor child,
                         SpriteBatch batch,
                         float parentAlpha)

applyTransform

protected void applyTransform(SpriteBatch batch)

updateTransform

protected Matrix4 updateTransform()

resetTransform

protected void resetTransform(SpriteBatch batch)

touchDown

public boolean touchDown(float x,
                         float y,
                         int pointer)
Specified by:
touchDown in class Actor

touchUp

public void touchUp(float x,
                    float y,
                    int pointer)
Specified by:
touchUp in class Actor

touchMoved

public boolean touchMoved(float x,
                          float y)
Overrides:
touchMoved in class Actor

touchDragged

public void touchDragged(float x,
                         float y,
                         int pointer)
Specified by:
touchDragged in class Actor

scrolled

public boolean scrolled(int amount)
Overrides:
scrolled in class Actor

keyDown

public boolean keyDown(int keycode)
Overrides:
keyDown in class Actor

keyUp

public boolean keyUp(int keycode)
Overrides:
keyUp in class Actor

keyTyped

public boolean keyTyped(char character)
Overrides:
keyTyped in class Actor

hit

public Actor hit(float x,
                 float y)
Specified by:
hit in class Actor

addActor

public void addActor(Actor actor)
Adds an Actor to this Group. The order Actors are added is reversed for hit testing.

Parameters:
actor - the Actor

addActorAt

public void addActorAt(int index,
                       Actor actor)
Adds an Actor at the given index in the group. The first Actor added will be at index 0 and so on. Throws an IndexOutOfBoundsException in case the index is invalid.

Parameters:
index - the index to add the actor at.

addActorBefore

public void addActorBefore(Actor actorBefore,
                           Actor actor)
Adds an Actor before the given Actor.

Parameters:
actorBefore - the Actor to add the other actor in front of
actor - the Actor to add

addActorAfter

public void addActorAfter(Actor actorAfter,
                          Actor actor)
Adds an Actor after the given Actor.

Parameters:
actorAfter - the Actor to add the other Actor behind
actor - the Actor to add

removeActor

public void removeActor(Actor actor)
Removes an Actor from this Group.

Parameters:
actor -

removeActorRecursive

public void removeActorRecursive(Actor actor)
Removes an Actor from this Group recursively by checking if the Actor is in this group or one of its child-groups.

Parameters:
actor - the Actor

findActor

public Actor findActor(java.lang.String name)
Finds the Actor with the given name in this Group and its children.

Parameters:
name - the name of the Actor
Returns:
the Actor or null

swapActor

public boolean swapActor(int first,
                         int second)
Swap two actors' sort order by index. 0 is lowest while getActors().size() - 1 is largest.

Parameters:
first - first Actor index
second - second Actor index
Returns:
false if indices are out of bound.

swapActor

public boolean swapActor(Actor first,
                         Actor second)
Swap two actors' sort order by reference.

Parameters:
first - first Actor
second - second Actor
Returns:
false if any of the Actors is not the child of this Group.

getActors

public java.util.List<Actor> getActors()
Returns:
all child Actors as an ordered list.

getGroups

public java.util.List<Group> getGroups()
Returns:
all child Groups as an unordered list.

focus

public void focus(Actor actor,
                  int pointer)
Sets the focus to the given child Actor. All subsequent touch events with the given pointer id will be passed to this child Actor. To unset the focus simply pass null.

Parameters:
actor - the Actor

keyboardFocus

public void keyboardFocus(Actor actor)
Sets the keyboard focus to the given child Actor. All subsequent keyboard events will be passed to that actor. To unfocus an actor simply pass null.

Parameters:
actor - the Actor

scrollFocus

public void scrollFocus(Actor actor)
Sets the scroll focus to the given child Actor. All subsequent scroll events will be passed to that actor. To unfocus an actor simply pass null.

Parameters:
actor - the Actor.

clear

public void clear()
Clears this Group, removing all contained Actors.


sortChildren

public void sortChildren(java.util.Comparator<Actor> comparator)
Sorts the children via the given Comparator.

Parameters:
comparator - the comparator.

unfocusAll

public void unfocusAll()
Unfocuses all Actor instance currently focused for touch and keyboard events. You should call this in case your app resumes to clear up any pressed states. Make sure the Actors forget their states as well! This will be applied to all child groups recursively.


unfocusAll

public void unfocusAll(Actor actor)
Unfocuses this Actor from the touch, keyboard and scroll focus from this group and all groups above it.

Parameters:
actor - the Actor

toChildCoordinates

public static void toChildCoordinates(Actor child,
                                      float x,
                                      float y,
                                      Vector2 out)
Transforms the coordinates given in the child's parent coordinate system to the child Actor's coordinate system.

Parameters:
child - the child Actor
x - the x-coordinate in the Group's coordinate system
y - the y-coordinate in the Group's coordinate system
out - the output Vector2

enableDebugging

public static void enableDebugging(java.lang.String debugTextureFile)

disableDebugging

public static void disableDebugging()

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)