|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
public class Group
2D scene graph node that may contain other actors.
Actors have a z-order equal to the order they were inserted into the group. Actors inserted later will be drawn on top of actors added earlier. Touch events that hit more than one actor are distributed to topmost actors first.
Constructor Summary | |
---|---|
Group()
|
Method Summary | |
---|---|
void |
act(float delta)
Updates the actor based on time. |
void |
addActor(Actor actor)
Adds an actor as a child of this group. |
void |
addActorAfter(Actor actorAfter,
Actor actor)
Adds an actor as a child of this group, immediately after another child actor. |
void |
addActorAt(int index,
Actor actor)
Adds an actor as a child of this group, at a specific index. |
void |
addActorBefore(Actor actorBefore,
Actor actor)
Adds an actor as a child of this group, immediately before another child actor. |
protected void |
applyTransform(SpriteBatch batch,
Matrix4 transform)
Set the SpriteBatch's transformation matrix, often with the result of computeTransform() . |
protected void |
childrenChanged()
Called when actors are added to or removed from the group. |
void |
clear()
Removes all actors from this group. |
protected Matrix4 |
computeTransform()
Returns the transform for this group's coordinate system. |
void |
draw(SpriteBatch batch,
float parentAlpha)
Draws the group and its children. |
protected void |
drawChildren(SpriteBatch batch,
float parentAlpha)
Draws all children. |
Actor |
findActor(java.lang.String name)
Returns the first actor found with the specified name. |
SnapshotArray<Actor> |
getChildren()
Returns an ordered list of child actors in this group. |
Actor |
hit(float x,
float y,
boolean touchable)
Returns the deepest actor that contains the specified point and is touchable and
visible , or null if no actor was hit. |
boolean |
isTransform()
|
Vector2 |
localToDescendantCoordinates(Actor descendant,
Vector2 localCoords)
Converts coordinates for this group to those of a descendant actor. |
boolean |
removeActor(Actor actor)
Removes an actor from this group. |
protected void |
resetTransform(SpriteBatch batch)
Restores the SpriteBatch transform to what it was before applyTransform(SpriteBatch, Matrix4) . |
void |
setCullingArea(Rectangle cullingArea)
Children completely outside of this rectangle will not be drawn. |
protected void |
setStage(Stage stage)
Called by the framework when this actor or any parent is added to a group that is in the stage. |
void |
setTransform(boolean transform)
When true (the default), the SpriteBatch is transformed so children are drawn in their parent's coordinate system. |
boolean |
swapActor(Actor first,
Actor second)
Swaps two actors. |
boolean |
swapActor(int first,
int second)
Swaps two actors by index. |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
addAction, addCaptureListener, addListener, clearActions, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getWidth, getX, getY, getZIndex, hasParent, isAscendantOf, isDescendantOf, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotate, scale, scale, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOriginX, setOriginY, setParent, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setVisible, setWidth, setX, setY, setZIndex, size, size, stageToLocalCoordinates, toBack, toFront, toString, translate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Group()
Method Detail |
---|
public void act(float delta)
Actor
Stage.act(float)
.
The default implementation calls Action.act(float)
on each action and removes actions that are complete.
act
in class Actor
delta
- Time in seconds since the last frame.public void draw(SpriteBatch batch, float parentAlpha)
applyTransform(SpriteBatch, Matrix4)
if needed,
then drawChildren(SpriteBatch, float)
, then resetTransform(SpriteBatch)
if needed.
draw
in class Actor
parentAlpha
- Should be multipied with the actor's alpha, allowing a parent's alpha to affect all children.protected void drawChildren(SpriteBatch batch, float parentAlpha)
applyTransform(SpriteBatch, Matrix4)
should be called before and
resetTransform(SpriteBatch)
after this method if transform
is true. If
transform
is false these methods don't need to be called, children positions are temporarily
offset by the group position when drawn. This method avoids drawing children completely outside the
culling area
, if set.
protected void applyTransform(SpriteBatch batch, Matrix4 transform)
computeTransform()
. Note this causes the
batch to be flushed. resetTransform(SpriteBatch)
will restore the transform to what it was before this call.
protected Matrix4 computeTransform()
protected void resetTransform(SpriteBatch batch)
applyTransform(SpriteBatch, Matrix4)
. Note this causes the
batch to be flushed.
public void setCullingArea(Rectangle cullingArea)
setCullingArea
in interface Cullable
cullingArea
- The culling area in the child actor's coordinates.public Actor hit(float x, float y, boolean touchable)
Actor
touchable
and
visible
, or null if no actor was hit. The point is specified in the actor's local coordinate system (0,0
is the bottom left of the actor and width,height is the upper right).
This method is used to delegate touchDown events. If this method returns null, touchDown will not occur.
The default implementation returns this actor if the point is within this actor's bounds.
hit
in class Actor
touchable
- If true, the hit detection will respect the touchability
.Touchable
protected void childrenChanged()
public void addActor(Actor actor)
Actor.remove()
public void addActorAt(int index, Actor actor)
index
- May be greater than the number of children.public void addActorBefore(Actor actorBefore, Actor actor)
public void addActorAfter(Actor actorAfter, Actor actor)
public boolean removeActor(Actor actor)
cleared
so the actions will be returned to their
pool
, if any. This is not done automatically.
public void clear()
public Actor findActor(java.lang.String name)
protected void setStage(Stage stage)
Actor
setStage
in class Actor
stage
- May be null if the actor or any parent is no longer in a stage.public boolean swapActor(int first, int second)
public boolean swapActor(Actor first, Actor second)
public SnapshotArray<Actor> getChildren()
public void setTransform(boolean transform)
SpriteBatch.flush()
must be done before and after the transform. If the actors in a
group are not rotated or scaled, then the transform for the group can be set to false. In this case, each child's position
will be offset by the group's position for drawing, causing the children to appear in the correct location even though the
SpriteBatch has not been transformed.
public boolean isTransform()
public Vector2 localToDescendantCoordinates(Actor descendant, Vector2 localCoords)
java.lang.IllegalArgumentException
- if the specified actor is not a descendant of this group.
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |