Package arc.scene
Class Group
java.lang.Object
arc.scene.Element
arc.scene.Group
- All Implemented Interfaces:
Cullable
- Direct Known Subclasses:
ResearchDialog.View
,WidgetGroup
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.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final SnapshotSeq<Element>
protected Rect
protected boolean
Fields inherited from class arc.scene.Element
color, cullable, fillParent, height, name, originX, originY, parent, parentAlpha, rotation, scaleX, scaleY, touchable, touchablility, translation, userObject, visibility, visible, width, x, y
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
act
(float delta) Updates the actor based on time.void
Adds an actor as a child of this group, removing it from its previous parent.void
addChildAfter
(Element actorAfter, Element actor) Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent.void
addChildAt
(int index, Element actor) Adds an actor as a child of this group at a specific index, removing it from its previous parent.void
addChildBefore
(Element actorBefore, Element actor) Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent.protected void
applyTransform
(Mat transform) Set the batch's transformation matrix, often with the result ofcomputeTransform()
.protected void
Called when actors are added to or removed from the group.void
clear()
Removes all children, actions, and listeners from this group.void
Removes all actors from this group.protected Mat
Returns the transform for this group's coordinate system.void
draw()
Draws the element.protected void
void
Adds and returns a table.void
Adds and returns a table.fill
(Table.DrawRect rect) <T extends Element>
TFind element by a predicate.<T extends Element>
TReturns the first actor found with the specified name.<T extends Element>
TfindVisible
(String name) Finds only visible elements.void
Recursively iterates through every child of this group.Returns an ordered list of child actors in this group.boolean
hit
(float x, float y, boolean touchable) Returns the deepest actor that contains the specified point and istouchable
andvisible
, or null if no actor was hit.boolean
localToDescendantCoordinates
(Element descendant, Vec2 localCoords) Converts coordinates for this group to those of a descendant actor.boolean
removeChild
(Element actor) Removes an actor from this group and unfocuses it.boolean
removeChild
(Element actor, boolean unfocus) Removes an actor from this group.protected void
Restores the batch transform to what it was beforeapplyTransform(Mat)
.void
setCullingArea
(Rect cullingArea) Children completely outside of this rectangle will not be drawn.protected void
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 Batch is transformed so children are drawn in their parent's coordinate system.boolean
swapActor
(int first, int second) Swaps two actors by index.boolean
Swaps two actors.toString()
Returns a description of the actor hierarchy, recursively.Methods inherited from class arc.scene.Element
actions, addAction, addCaptureListener, addListener, change, changed, clearActions, clearListeners, clicked, clicked, clicked, clicked, clipBegin, clipBegin, clipEnd, dragged, exited, fire, fireClick, getActions, getCaptureListeners, getHeight, getListeners, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, getRight, getRotation, getScene, getTop, getWidth, getX, getY, getZIndex, hasActions, hasKeyboard, hasMouse, hasParent, hasScroll, hovered, invalidate, invalidateHierarchy, isAscendantOf, isDescendantOf, isDescendantOf, isTouchable, keepInStage, keyDown, keyDown, layout, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, needsLayout, notify, pack, parentToLocalCoordinates, released, remove, removeAction, removeCaptureListener, removeListener, requestKeyboard, requestScroll, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, scrolled, setBounds, setColor, setColor, setFillParent, setHeight, setLayoutEnabled, setOrigin, setOrigin, setPosition, setPosition, setRotation, setRotationOrigin, setScale, setScale, setSize, setSize, setTranslation, setWidth, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, tapped, toBack, toFront, touchable, update, updateVisibility, validate, visible
-
Field Details
-
children
-
transform
protected boolean transform -
cullingArea
-
-
Constructor Details
-
Group
public Group()
-
-
Method Details
-
act
public void act(float delta) Description copied from class:Element
Updates the actor based on time. Typically this is called each frame byScene.act(float)
.The default implementation calls
Action.act(float)
on each action and removes actions that are complete. -
draw
public void draw()Description copied from class:Element
Draws the element. Does nothing by default. -
drawChildren
protected void drawChildren() -
computeTransform
Returns the transform for this group's coordinate system. -
applyTransform
Set the batch's transformation matrix, often with the result ofcomputeTransform()
. Note this causes the batch to be flushed.resetTransform()
will restore the transform to what it was before this call. -
resetTransform
protected void resetTransform()Restores the batch transform to what it was beforeapplyTransform(Mat)
. Note this causes the batch to be flushed. -
getCullingArea
- Returns:
- May be null.
- See Also:
-
setCullingArea
Children completely outside of this rectangle will not be drawn. This is only valid for use with unrotated and unscaled actors.- Specified by:
setCullingArea
in interfaceCullable
- Parameters:
cullingArea
- May be null.
-
hit
Description copied from class:Element
Returns the deepest actor that contains the specified point and istouchable
andvisible
, 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, mouse, and enter/exit events. If this method returns null, those events will not occur on this Actor.
The default implementation returns this actor if the point is within this actor's bounds.
-
childrenChanged
protected void childrenChanged()Called when actors are added to or removed from the group. -
forEach
Recursively iterates through every child of this group. -
fill
-
fill
Adds and returns a table. This table will fill the whole scene. -
fill
Adds and returns a table. This table will fill the whole scene. -
addChild
Adds an actor as a child of this group, removing it from its previous parent. If the actor is already a child of this group, no changes are made. -
addChildAt
Adds an actor as a child of this group at a specific index, removing it from its previous parent. If the actor is already a child of this group, no changes are made.- Parameters:
index
- May be greater than the number of children.
-
addChildBefore
Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent. If the actor is already a child of this group, no changes are made. -
addChildAfter
Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent. If the actor is already a child of this group, no changes are made. -
removeChild
Removes an actor from this group and unfocuses it. CallsremoveChild(Element, boolean)
with true. -
removeChild
Removes an actor from this group. If the actor will not be used again and has actions, they should becleared
so the actions will be returned to theirpool
, if any. This is not done automatically.- Parameters:
unfocus
- If true,Scene.unfocus(Element)
is called.- Returns:
- true if the actor was removed from this group.
-
clearChildren
public void clearChildren()Removes all actors from this group. -
clear
public void clear()Removes all children, actions, and listeners from this group. -
find
Returns the first actor found with the specified name. Note this recursively compares the name of every actor in the group. -
findVisible
Finds only visible elements. -
find
Find element by a predicate. -
setScene
Description copied from class:Element
Called by the framework when this actor or any parent is added to a group that is in the stage. -
swapActor
public boolean swapActor(int first, int second) Swaps two actors by index. Returns false if the swap did not occur because the indexes were out of bounds. -
swapActor
Swaps two actors. Returns false if the swap did not occur because the actors are not children of this group. -
getChildren
Returns an ordered list of child actors in this group. -
hasChildren
public boolean hasChildren() -
isTransform
public boolean isTransform() -
setTransform
public void setTransform(boolean transform) When true (the default), the Batch is transformed so children are drawn in their parent's coordinate system. This has a performance impact becauseBatch.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 Batch has not been transformed. -
localToDescendantCoordinates
Converts coordinates for this group to those of a descendant actor. The descendant does not need to be a direct child. -
toString
Returns a description of the actor hierarchy, recursively.
-