Package playn.scene
Class GroupLayer
java.lang.Object
playn.scene.Layer
playn.scene.ClippedLayer
playn.scene.GroupLayer
- All Implemented Interfaces:
AutoCloseable
,Iterable<Layer>
,Closeable
- Direct Known Subclasses:
RootLayer
GroupLayer creates a Layer hierarchy by maintaining an ordered group of child Layers.
-
Nested Class Summary
Nested classes/interfaces inherited from class playn.scene.Layer
Layer.HitTester, Layer.Origin, Layer.State, Layer.Visitor
Nested classes/interfaces inherited from interface react.Closeable
Closeable.Set, Closeable.Util
-
Field Summary
Fields inherited from class playn.scene.Layer
DEBUG_RECTS, state
-
Constructor Summary
ConstructorDescriptionCreates an unclipped group layer.GroupLayer
(float width, float height) Creates a clipped group layer with the specified size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a layer to the bottom of the group.void
Adds all supplied children to this layer, in order.void
Adds the supplied layer to this group layer, adjusting its translation (relative to this group layer) to the supplied values.void
addCenterAt
(Layer child, float tx, float ty) Addschild
to this group layer, positioning it such that its center is at (tx
,tx
).void
addFloorAt
(Layer child, float tx, float ty) Addschild
to this group layer, adjusting its translation (relative to this group layer) tofloor(tx), floor(ty)
.childAt
(int index) Returns the layer at the specified index.int
children()
Returns the number of child layers in this group.void
close()
Disposes this layer, removing it from its parent layer.void
Removes and disposes all child layers from this group.hitTestDefault
(Point point) LikeLayer.hitTest(pythagoras.f.Point)
except that it ignores a configuredLayer.HitTester
.boolean
isEmpty()
Returns whether this group has any child layers.iterator()
void
Removes a layer from the group.void
Removes all supplied children from this layer, in order.void
Removes all child layers from this group.Methods inherited from class playn.scene.ClippedLayer
height, setHeight, setSize, setSize, setWidth, width
Methods inherited from class playn.scene.Layer
absorbHits, alpha, debugPrint, depth, disposed, events, hasEventListeners, hitTest, interactive, name, onAdded, onDisposed, onRemoved, origin, origin, originX, originY, paint, parent, rotation, scale, scaledHeight, scaledWidth, scaleX, scaleY, setAlpha, setBatch, setDepth, setHitTester, setInteractive, setName, setOrigin, setOrigin, setRotation, setScale, setScale, setScaleX, setScaleY, setTint, setTranslation, setTranslation, setTx, setTy, setVisible, tint, toString, transform, translation, translation, tx, ty, visible, visit
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
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
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
Adds a layer to the bottom of the group. Because theLayer
hierarchy is a tree, ifchild
is already a child of anotherGroupLayer
, it will be removed before being added to thisGroupLayer
. -
add
Adds all supplied children to this layer, in order. Seeadd(Layer)
. -
addAt
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
Addschild
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
Addschild
to this group layer, adjusting its translation (relative to this group layer) tofloor(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
Removes a layer from the group. -
remove
Removes all supplied children from this layer, in order. Seeremove(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
-
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. -
hitTestDefault
Description copied from class:Layer
LikeLayer.hitTest(pythagoras.f.Point)
except that it ignores a configuredLayer.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 classLayer
-