A 2D game object, parent of all 2D-related nodes. Has a position, rotation, scale and Z index.
    public class Node2D : CanvasItem

A 2D game object, with a position, rotation and scale. All 2D physics nodes and sprites inherit from Node2D. Use Node2D as a parent node to move, scale and rotate children in a 2D project. Also gives control on the node’s render order.

Inheritance Chain

Derived Classes

Constructors

    public Node2D()

Properties

    public Vector2 GlobalPosition { get; set; }

Global position.

    public float GlobalRotation { get; set; }

Global rotation in radians.

    public float GlobalRotationDegrees { get; set; }

Global rotation in degrees.

    public Vector2 GlobalScale { get; set; }

Global scale.

    public Transform2D GlobalTransform { get; set; }

Global Transform2D.

    public Vector2 Position { get; set; }

Position, relative to the node’s parent.

    public float Rotation { get; set; }

Rotation in radians, relative to the node’s parent.

    public float RotationDegrees { get; set; }

Rotation in degrees, relative to the node’s parent.

    public Vector2 Scale { get; set; }

The node’s scale. Unscaled value: (1, 1).

    public Transform2D Transform { get; set; }

Local Transform2D.

    public bool ZAsRelative { get; set; }

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.

    public int ZIndex { get; set; }

Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others.

Methods

    public void ApplyScale(Vector2 ratio)

Multiplies the current scale by the ratio vector.

    public float GetAngleTo(Vector2 point)

Returns the angle between the node and the point in radians.

    [Obsolete("GetGlobalPosition is deprecated. Use the GlobalPosition property instead.")]
    public Vector2 GetGlobalPosition()

Getter for GlobalPosition

    [Obsolete("GetGlobalRotation is deprecated. Use the GlobalRotation property instead.")]
    public float GetGlobalRotation()

Getter for GlobalRotation

    [Obsolete("GetGlobalRotationDegrees is deprecated. Use the GlobalRotationDegrees property instead.")]
    public float GetGlobalRotationDegrees()

Getter for GlobalRotationDegrees

    [Obsolete("GetGlobalScale is deprecated. Use the GlobalScale property instead.")]
    public Vector2 GetGlobalScale()

Getter for GlobalScale

    [Obsolete("GetPosition is deprecated. Use the Position property instead.")]
    public Vector2 GetPosition()

Getter for Position

    public Transform2D GetRelativeTransformToParent(Node parent)

Returns the Transform2D relative to this node’s parent.

    [Obsolete("GetRotation is deprecated. Use the Rotation property instead.")]
    public float GetRotation()

Getter for Rotation

    [Obsolete("GetRotationDegrees is deprecated. Use the RotationDegrees property instead.")]
    public float GetRotationDegrees()

Getter for RotationDegrees

    [Obsolete("GetScale is deprecated. Use the Scale property instead.")]
    public Vector2 GetScale()

Getter for Scale

    [Obsolete("GetZIndex is deprecated. Use the ZIndex property instead.")]
    public int GetZIndex()

Getter for ZIndex

    public void GlobalTranslate(Vector2 offset)

Adds the offset vector to the node’s global position.

    [Obsolete("IsZRelative is deprecated. Use the ZAsRelative property instead.")]
    public bool IsZRelative()

Getter for ZAsRelative

    public void LookAt(Vector2 point)

Rotates the node so it points towards the point, which is expected to use global coordinates.

    public void MoveLocalX(float delta, bool scaled = false)

Applies a local translation on the node’s X axis based on the Node._Process(float)’s delta. If scaled is false, normalizes the movement.

    public void MoveLocalY(float delta, bool scaled = false)

Applies a local translation on the node’s Y axis based on the Node._Process(float)’s delta. If scaled is false, normalizes the movement.

    public void Rotate(float radians)

Applies a rotation to the node, in radians, starting from its current rotation.

    [Obsolete("SetGlobalPosition is deprecated. Use the GlobalPosition property instead.")]
    public void SetGlobalPosition(Vector2 position)

Setter for GlobalPosition

    [Obsolete("SetGlobalRotation is deprecated. Use the GlobalRotation property instead.")]
    public void SetGlobalRotation(float radians)

Setter for GlobalRotation

    [Obsolete("SetGlobalRotationDegrees is deprecated. Use the GlobalRotationDegrees property instead.")]
    public void SetGlobalRotationDegrees(float degrees)

Setter for GlobalRotationDegrees

    [Obsolete("SetGlobalScale is deprecated. Use the GlobalScale property instead.")]
    public void SetGlobalScale(Vector2 scale)

Setter for GlobalScale

    [Obsolete("SetGlobalTransform is deprecated. Use the GlobalTransform property instead.")]
    public void SetGlobalTransform(Transform2D xform)

Setter for GlobalTransform

    [Obsolete("SetPosition is deprecated. Use the Position property instead.")]
    public void SetPosition(Vector2 position)

Setter for Position

    [Obsolete("SetRotation is deprecated. Use the Rotation property instead.")]
    public void SetRotation(float radians)

Setter for Rotation

    [Obsolete("SetRotationDegrees is deprecated. Use the RotationDegrees property instead.")]
    public void SetRotationDegrees(float degrees)

Setter for RotationDegrees

    [Obsolete("SetScale is deprecated. Use the Scale property instead.")]
    public void SetScale(Vector2 scale)

Setter for Scale

    [Obsolete("SetTransform is deprecated. Use the Transform property instead.")]
    public void SetTransform(Transform2D xform)

Setter for Transform

    [Obsolete("SetZAsRelative is deprecated. Use the ZAsRelative property instead.")]
    public void SetZAsRelative(bool enable)

Setter for ZAsRelative

    [Obsolete("SetZIndex is deprecated. Use the ZIndex property instead.")]
    public void SetZIndex(int zIndex)

Setter for ZIndex

    public Vector2 ToGlobal(Vector2 localPoint)

Converts a local point’s coordinates to global coordinates.

    public Vector2 ToLocal(Vector2 globalPoint)

Converts a global point’s coordinates to local coordinates.

    public void Translate(Vector2 offset)

Translates the node by the given offset in local coordinates.

Tags: