Package com.prineside.tdi2.scene2d
Class Group
java.lang.Object
com.prineside.tdi2.scene2d.Actor
com.prineside.tdi2.scene2d.Group
- All Implemented Interfaces:
Cullable
- Direct Known Subclasses:
AbilitySlotButton
,AimStrategySelector
,AttentionRaysUnderlay
,BossHpBar
,ComplexButton
,ExpLine
,GameplayBonusSummary
,GroupClipping
,HorizontalSlider
,HotKeyHintLabel
,ItemCell
,MapEditorInventoryMenu.ItemSlot
,Notifications
,Notifications.Notification
,OverlayContinueButton
,PaddedImageButton
,QuestList.QuestListItem
,ResearchScreenInventory
,RightSideMenuButton
,SellButton
,SideMenu.SideMenuContainer
,TileResources
,TowerAbilityButton
,UpgradeSubmenu
,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.
- Author:
- mzechner, Nathan Sweet
-
Constructor Summary
Constructors -
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
addActorAfter
(Actor actorAfter, Actor actor) Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent.void
addActorAt
(int index, Actor actor) Adds an actor as a child of this group at a specific index, removing it from its previous parent.void
addActorBefore
(Actor actorBefore, Actor actor) Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent.void
clear()
Removes all children, actions, and listeners from this group.void
clear
(boolean unfocus) Removes all children, actions, and listeners from this group.void
Removes all actors from this group and unfocuses them.void
clearChildren
(boolean unfocus) Removes all actors from this group.debugAll()
CallssetDebug(boolean, boolean)
withtrue, true
.void
Draws the group and its children.void
drawDebug
(ShapeRenderer shapes) Draws this actor's debug lines ifActor.getDebug()
is true and, regardless ofActor.getDebug()
, callsActor.drawDebug(ShapeRenderer)
on each child.<T extends Actor>
TReturns the first actor found with the specified name.getChild
(int index) Returns the child at the specified index.Returns an ordered list of child actors in this group.boolean
hit
(float x, float y, boolean touchable) boolean
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 and unfocuses it.boolean
removeActor
(Actor actor, boolean unfocus) Removes an actor from this group.removeActorAt
(int index, boolean unfocus) Removes an actor from this group.void
setCullingArea
(Rectangle cullingArea) Children completely outside of this rectangle will not be drawn.void
setDebug
(boolean enabled, boolean recursively) If true,drawDebug(ShapeRenderer)
will be called for this group and, optionally, all children recursively.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 com.prineside.tdi2.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
Constructor Details
-
Group
public Group()
-
-
Method Details
-
act
public void act(float delta) Description copied from class:Actor
Updates the actor based on time. Typically this is called each frame byStage.act(float)
.The default implementation calls
Action.act(float)
on each action and removes actions that are complete. -
draw
Draws the group and its children. The default implementation callsapplyTransform(Batch, Matrix4)
if needed, thendrawChildren(Batch, float)
, thenresetTransform(Batch)
if needed. -
drawDebug
Draws this actor's debug lines ifActor.getDebug()
is true and, regardless ofActor.getDebug()
, callsActor.drawDebug(ShapeRenderer)
on each child. -
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.
-
getCullingArea
- Returns:
- May be null.
- See Also:
-
hit
Description copied from class:Actor
Returns the deepestvisible
(and optionally,touchable
) actor that contains the specified point, 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 and this actor is visible.
- Overrides:
hit
in classActor
touchable
- If true, hit detection will respect thetouchability
.- See Also:
-
addActor
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. -
addActorAt
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.
-
addActorBefore
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. -
addActorAfter
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. IfactorAfter
is not in this group, the actor is added as the last child. -
removeActor
Removes an actor from this group and unfocuses it. CallsremoveActor(Actor, boolean)
with true. -
removeActor
Removes an actor from this group. CallsremoveActorAt(int, boolean)
with the actor's child index. -
removeActorAt
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,Stage.unfocus(Actor)
is called.- Returns:
- the actor removed from this group.
-
clearChildren
public void clearChildren()Removes all actors from this group and unfocuses them. CallsclearChildren(boolean)
with true. -
clearChildren
public void clearChildren(boolean unfocus) Removes all actors from this group. -
clear
public void clear()Removes all children, actions, and listeners from this group. The children are unfocused. -
clear
public void clear(boolean unfocus) Removes all children, actions, and listeners from this group. -
findActor
Returns the first actor found with the specified name. Note this recursively compares the name of every actor in the group. -
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. -
getChild
Returns the child at the specified index. -
getChildren
Returns an ordered list of child actors in this group. -
hasChildren
public boolean hasChildren() -
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. -
isTransform
public boolean isTransform() -
localToDescendantCoordinates
Converts coordinates for this group to those of a descendant actor. The descendant does not need to be an immediate child.- Throws:
IllegalArgumentException
- if the specified actor is not a descendant of this group.
-
setDebug
public void setDebug(boolean enabled, boolean recursively) If true,drawDebug(ShapeRenderer)
will be called for this group and, optionally, all children recursively. -
debugAll
CallssetDebug(boolean, boolean)
withtrue, true
. -
toString
Returns a description of the actor hierarchy, recursively.
-