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

public class Group extends Actor implements Cullable
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 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 by Stage.act(float).

      The default implementation calls Action.act(float) on each action and removes actions that are complete.

      Overrides:
      act in class Actor
      Parameters:
      delta - Time in seconds since the last frame.
    • draw

      public void draw(Batch batch, float parentAlpha)
      Draws the group and its children. The default implementation calls applyTransform(Batch, Matrix4) if needed, then drawChildren(Batch, float), then resetTransform(Batch) if needed.
      Overrides:
      draw in class Actor
      parentAlpha - The parent alpha, to be multiplied with this actor's alpha, allowing the parent's alpha to affect all children.
    • drawDebug

      public void drawDebug(ShapeRenderer shapes)
      Draws this actor's debug lines if Actor.getDebug() is true and, regardless of Actor.getDebug(), calls Actor.drawDebug(ShapeRenderer) on each child.
      Overrides:
      drawDebug in class Actor
    • setCullingArea

      public void setCullingArea(@Null Rectangle cullingArea)
      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 interface Cullable
      Parameters:
      cullingArea - May be null.
    • getCullingArea

      @Null public Rectangle getCullingArea()
      Returns:
      May be null.
      See Also:
    • hit

      @Null public Actor hit(float x, float y, boolean touchable)
      Description copied from class: Actor
      Returns the deepest visible (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 class Actor
      touchable - If true, hit detection will respect the touchability.
      See Also:
    • addActor

      public void addActor(Actor actor)
      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

      public 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. 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

      public 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. If the actor is already a child of this group, no changes are made.
    • addActorAfter

      public 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. If the actor is already a child of this group, no changes are made. If actorAfter is not in this group, the actor is added as the last child.
    • removeActor

      public boolean removeActor(Actor actor)
      Removes an actor from this group and unfocuses it. Calls removeActor(Actor, boolean) with true.
    • removeActor

      public boolean removeActor(Actor actor, boolean unfocus)
      Removes an actor from this group. Calls removeActorAt(int, boolean) with the actor's child index.
    • removeActorAt

      public Actor removeActorAt(int index, boolean unfocus)
      Removes an actor from this group. If the actor will not be used again and has actions, they should be cleared so the actions will be returned to their pool, 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. Calls clearChildren(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.
      Overrides:
      clear in class Actor
    • clear

      public void clear(boolean unfocus)
      Removes all children, actions, and listeners from this group.
    • findActor

      @Null public <T extends Actor> T findActor(String name)
      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

      public boolean swapActor(Actor first, Actor second)
      Swaps two actors. Returns false if the swap did not occur because the actors are not children of this group.
    • getChild

      public Actor getChild(int index)
      Returns the child at the specified index.
    • getChildren

      public SnapshotArray<Actor> 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 because Batch.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

      public Vector2 localToDescendantCoordinates(Actor descendant, Vector2 localCoords)
      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

      public Group debugAll()
      Calls setDebug(boolean, boolean) with true, true.
    • toString

      public String toString()
      Returns a description of the actor hierarchy, recursively.
      Overrides:
      toString in class Actor