Package playn.scene
Class LayerUtil
java.lang.Object
playn.scene.LayerUtil
Utility class for transforming coordinates between
Layers.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAutomatically connectsonPainttopaintwhenlayeris added to a scene graph, and disconnects it whenlayeris removed.static voidbind(Layer layer, Signal<Clock> update, Slot<Clock> onUpdate, Signal<Clock> paint, Slot<Clock> onPaint) Automatically connectsonUpdatetoupdate, andonPainttopaintwhenlayeris added to a scene graph, and disconnects them whenlayeris removed.static LayergetHitLayer(Layer root, Point p) Returns the layer hit by (screen) positionp(or null) in the scene graph rooted atroot, usingLayer.hitTest(pythagoras.f.Point).static intgraphDepth(Layer layer) Returns the depth of the given layer in its local scene graph.static booleanReturns true if a coordinate on the screen touches aLayer.static booleanstatic intindexInParent(Layer layer) Returns the index of the given layer within its parent, or -1 if the parent is null.static PointlayerToParent(Layer layer, Layer parent, float x, float y) Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer.static PointlayerToParent(Layer layer, Layer parent, XY point, Point into) Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer.static PointlayerToScreen(Layer layer, float x, float y) Converts the supplied point from coordinates relative to the specified layer to screen coordinates.static PointlayerToScreen(Layer layer, XY point, Point into) Converts the supplied point from coordinates relative to the specified layer to screen coordinates.static LayerlayerUnderPoint(Layer root, float x, float y) Gets the layer underneath the given screen coordinates, ignoring hit testers.static PointparentToLayer(Layer parent, Layer layer, XY point, Point into) Converts the supplied point from coordinates relative to the specified parent to coordinates relative to the specified child layer.static PointparentToLayer(Layer layer, XY point, Point into) Converts the supplied point from coordinates relative to its parent to coordinates relative to the specified layer.static voidPrints the layer heirarchy starting atlayer, usingLog.debug(java.lang.String).static PointscreenToLayer(Layer layer, float x, float y) Converts the supplied point from screen coordinates to coordinates relative to the specified layer.static PointscreenToLayer(Layer layer, XY point, Point into) Converts the supplied point from screen coordinates to coordinates relative to the specified layer.
-
Constructor Details
-
LayerUtil
public LayerUtil()
-
-
Method Details
-
layerToScreen
Converts the supplied point from coordinates relative to the specified layer to screen coordinates. The results are stored intointo, which is returned for convenience. -
layerToScreen
Converts the supplied point from coordinates relative to the specified layer to screen coordinates. -
layerToParent
Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer. The results are stored intointo, which is returned for convenience. -
layerToParent
Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer. -
screenToLayer
Converts the supplied point from screen coordinates to coordinates relative to the specified layer. The results are stored intointo, which is returned for convenience. -
screenToLayer
Converts the supplied point from screen coordinates to coordinates relative to the specified layer. -
parentToLayer
Converts the supplied point from coordinates relative to its parent to coordinates relative to the specified layer. The results are stored intointo, which is returned for convenience. -
parentToLayer
Converts the supplied point from coordinates relative to the specified parent to coordinates relative to the specified child layer. The results are stored intointo, which is returned for convenience. -
getHitLayer
Returns the layer hit by (screen) positionp(or null) in the scene graph rooted atroot, usingLayer.hitTest(pythagoras.f.Point). Note thatpis mutated by this call. -
hitTest
-
hitTest
Returns true if a coordinate on the screen touches aLayer. Note: if the supplied layer has no size, this will always return false. -
layerUnderPoint
Gets the layer underneath the given screen coordinates, ignoring hit testers. This is useful for inspecting the scene graph for debugging purposes, and is not intended for use is shipped code. The layer returned is the one that has a size and is the deepest within the graph and contains the coordinate. -
indexInParent
Returns the index of the given layer within its parent, or -1 if the parent is null. -
bind
Automatically connectsonPainttopaintwhenlayeris added to a scene graph, and disconnects it whenlayeris removed. -
bind
public static void bind(Layer layer, Signal<Clock> update, Slot<Clock> onUpdate, Signal<Clock> paint, Slot<Clock> onPaint) Automatically connectsonUpdatetoupdate, andonPainttopaintwhenlayeris added to a scene graph, and disconnects them whenlayeris removed. -
graphDepth
Returns the depth of the given layer in its local scene graph. A root layer (one with null parent) will always return 0. -
print
Prints the layer heirarchy starting atlayer, usingLog.debug(java.lang.String).
-