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.

    public Vector2 GetGlobalPosition()

Getter for GlobalPosition

    public float GetGlobalRotation()

Getter for GlobalRotation

    public float GetGlobalRotationDegrees()

Getter for GlobalRotationDegrees

    public Vector2 GetGlobalScale()

Getter for GlobalScale

    public Vector2 GetPosition()

Getter for Position

    public Transform2D GetRelativeTransformToParent(Node parent)

Returns the Transform2D relative to this node’s parent.

    public float GetRotation()

Getter for Rotation

    public float GetRotationDegrees()

Getter for RotationDegrees

    public Vector2 GetScale()

Getter for Scale

    public int GetZIndex()

Getter for ZIndex

    public void GlobalTranslate(Vector2 offset)

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

    public bool IsZRelative()

Getter for ZAsRelative

    public void LookAt(Vector2 point)

Rotates the node so it points towards the ‘point’.

    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.

    public void SetGlobalPosition(Vector2 position)

Setter for GlobalPosition

    public void SetGlobalRotation(float radians)

Setter for GlobalRotation

    public void SetGlobalRotationDegrees(float degrees)

Setter for GlobalRotationDegrees

    public void SetGlobalScale(Vector2 scale)

Setter for GlobalScale

    public void SetGlobalTransform(Transform2D xform)

Setter for GlobalTransform

    public void SetPosition(Vector2 position)

Setter for Position

    public void SetRotation(float radians)

Setter for Rotation

    public void SetRotationDegrees(float degrees)

Setter for RotationDegrees

    public void SetScale(Vector2 scale)

Setter for Scale

    public void SetTransform(Transform2D xform)

Setter for Transform

    public void SetZAsRelative(bool enable)

Setter for ZAsRelative

    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: