Struct Node2D
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
struct Node2D
;
A 2D game object, with a transform (position, rotation, and scale). All 2D nodes, including physics objects and sprites, inherit from Node2D. Use Node2D as a parent node to move, scale and rotate children in a 2D project. Also gives control of the node's render order.
Properties
Name | Type | Description |
---|---|---|
globalPosition [get, set]
|
Vector2 | Global position. |
globalRotation [get, set]
|
double | Global rotation in radians. |
globalRotationDegrees [get, set]
|
double | Global rotation in degrees. |
globalScale [get, set]
|
Vector2 | Global scale. |
globalTransform [get, set]
|
Transform2D | Global Transform2D .
|
position [get, set]
|
Vector2 | Position, relative to the node's parent. |
rotation [get, set]
|
double | Rotation in radians, relative to the node's parent. |
rotationDegrees [get, set]
|
double | Rotation in degrees, relative to the node's parent. |
scale [get, set]
|
Vector2 | The node's scale. Unscaled value: (1, 1) .
|
transform [get, set]
|
Transform2D | Local Transform2D .
|
zAsRelative [get, set]
|
bool | If true , the node's Z index is relative to its parent's Z index. If this node's Z index is 2 and its parent's effective Z index is 3, then this node's effective Z index will be 2 + 3 = 5.
|
zIndex [get, set]
|
long | Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others. |
Methods
Name | Description |
---|---|
applyScale
|
Multiplies the current scale by the ratio vector.
|
getAngleTo
|
Returns the angle between the node and the point in radians.
|
getGlobalPosition
|
|
getGlobalRotation
|
|
getGlobalRotationDegrees
|
|
getGlobalScale
|
|
getPosition
|
|
getRelativeTransformToParent
|
Returns the Transform2D relative to this node's parent.
|
getRotation
|
|
getRotationDegrees
|
|
getScale
|
|
getZIndex
|
|
globalTranslate
|
Adds the offset vector to the node's global position.
|
isZRelative
|
|
lookAt
|
Rotates the node so it points towards the point , which is expected to use global coordinates.
|
moveLocalX
|
Applies a local translation on the node's X axis based on the Node 's delta . If scaled is false , normalizes the movement.
|
moveLocalY
|
Applies a local translation on the node's Y axis based on the Node 's delta . If scaled is false , normalizes the movement.
|
rotate
|
Applies a rotation to the node, in radians, starting from its current rotation. |
setGlobalPosition
|
|
setGlobalRotation
|
|
setGlobalRotationDegrees
|
|
setGlobalScale
|
|
setGlobalTransform
|
|
setPosition
|
|
setRotation
|
|
setRotationDegrees
|
|
setScale
|
|
setTransform
|
|
setZAsRelative
|
|
setZIndex
|
|
toGlobal
|
Converts a local point's coordinates to global coordinates. |
toLocal
|
Converts a global point's coordinates to local coordinates. |
translate
|
Translates the node by the given offset in local coordinates.
|