Interface StageNode2D
Nodes have two different "transforms", which determines how and where they are drawn by the renderer. The local transform is interpreted relative to its parent node. Combining a node's local transform with the transform of its parent results in its global transform, which is interpreted relative to the stage.
Nodes do not implement the Updatable
interface. Nodes are not expected to be updated every frame: The
renderer will generally not draw graphics that are not currently visible,
for performance reasons. Therefore, instead of relying on frame updates,
the renderer will use animate(Timer) to update currently visible
nodes while rendering the stage.
Although the stage can contain both 2D and 3D graphics, it has a hard
separation between the two. Refer to StageNode3D for the equivalent
interface for 2D graphics.
-
Method Summary
Modifier and TypeMethodDescriptionvoidCalled by the renderer at the end of frame updates, while rendering the stage.Returns this node's global transform, which is interpreted relative to the stage.Returns the bounding box currently occopied by this node, relative to the stage.Returns this node's local transform, which is interpreted relative to its parent node.default voidsetPosition(float x, float y) Deprecated.
-
Method Details
-
animate
Called by the renderer at the end of frame updates, while rendering the stage.animationTimercontains the elapsed time since the currently active scene was started. This allows animations to display correctly, without the need to update every single node during each frame update. -
getTransform
Transform getTransform()Returns this node's local transform, which is interpreted relative to its parent node. The local transform can be modified by application code to modify how and where the node is displayed. -
getGlobalTransform
Transform getGlobalTransform()Returns this node's global transform, which is interpreted relative to the stage. The global transform is updated by the renderer when drawing the stage at the end of frame updates. Recalculating the global transform is relatively expensive, and is therefore only done once per frame. This means that any changes made to a node's local transform since the last frame update may not yet been reflected in the current state of its global transform. -
getStageBounds
Rect getStageBounds()Returns the bounding box currently occopied by this node, relative to the stage. This method usesgetGlobalTransform(). -
setPosition
Deprecated.Prefer usinggetTransform().setPosition(x, y).Convenience method of changing this graphic's position. The X and Y coordinates are relative to the graphic's local transform.
-
getTransform().setPosition(x, y).