Package playn.scene

Class GroupLayer

All Implemented Interfaces:
AutoCloseable, Iterable<Layer>, Closeable
Direct Known Subclasses:
RootLayer

public class GroupLayer extends ClippedLayer implements Iterable<Layer>
GroupLayer creates a Layer hierarchy by maintaining an ordered group of child Layers.
  • Constructor Details

    • GroupLayer

      public GroupLayer()
      Creates an unclipped group layer. Unclipped groups have no defined size.
    • GroupLayer

      public GroupLayer(float width, float height)
      Creates a clipped group layer with the specified size.
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns whether this group has any child layers.
    • children

      public int children()
      Returns the number of child layers in this group.
    • childAt

      public Layer childAt(int index)
      Returns the layer at the specified index. Layers are ordered in terms of their depth and will be returned in this order, with 0 being the layer on bottom.
    • add

      public void add(Layer child)
      Adds a layer to the bottom of the group. Because the Layer hierarchy is a tree, if child is already a child of another GroupLayer, it will be removed before being added to this GroupLayer.
    • add

      public void add(Layer child0, Layer child1, Layer... childN)
      Adds all supplied children to this layer, in order. See add(Layer).
    • addAt

      public void addAt(Layer child, float tx, float ty)
      Adds the supplied layer to this group layer, adjusting its translation (relative to this group layer) to the supplied values.

      This is equivalent to: add(child.setTranslation(tx, ty)).

    • addCenterAt

      public void addCenterAt(Layer child, float tx, float ty)
      Adds child to this group layer, positioning it such that its center is at (tx, tx). The layer must report a non-zero size, thus this will not work on an unclipped group layer.

      This is equivalent to: add(child.setTranslation(tx - child.width()/2, ty - child.height()/2)).

    • addFloorAt

      public void addFloorAt(Layer child, float tx, float ty)
      Adds child to this group layer, adjusting its translation (relative to this group layer) to floor(tx), floor(ty). This is useful for adding layers which display text a text can become blurry if it is positioned on sub-pixel boundaries.
    • remove

      public void remove(Layer child)
      Removes a layer from the group.
    • remove

      public void remove(Layer child0, Layer child1, Layer... childN)
      Removes all supplied children from this layer, in order. See remove(Layer).
    • removeAll

      public void removeAll()
      Removes all child layers from this group.
    • disposeAll

      public void disposeAll()
      Removes and disposes all child layers from this group.
    • iterator

      public Iterator<Layer> iterator()
      Specified by:
      iterator in interface Iterable<Layer>
    • close

      public void close()
      Description copied from class: Layer
      Disposes this layer, removing it from its parent layer. Any resources associated with this layer are freed, and it cannot be reused after being disposed. Disposing a layer that has children will dispose them as well.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class Layer
    • hitTestDefault

      public Layer hitTestDefault(Point point)
      Description copied from class: Layer
      Like Layer.hitTest(pythagoras.f.Point) except that it ignores a configured Layer.HitTester. This allows one to configure a hit tester which checks custom properties and then falls back on the default hit testing implementation.
      Overrides:
      hitTestDefault in class Layer