← Back to Documentation

Node2D

⚠️ Experimental - Pre-Release

Inheritance Hierarchy

Inherits:
Inheritance Chain:
Node → Node2D

Node2D is a 2D node that extends Node and adds 2D positioning and transform capabilities. Use Node2D for any 2D game object that needs a position in 2D space.

Basic Usage

@script Player extends Node2D    var speed = 5.0     fn update() {        var delta = Time.get_delta()        self.transform.position.x += speed * delta    }

Fields

transform: Transform2D

The 2D transform containing position, rotation, and scale.

@script Player extends Node2D    fn update() {        self.transform.position.x = 100        self.transform.position.y = 50        self.transform.rotation = 45.0        self.transform.scale.x = 1.5    }

pivot: Vector2

The pivot point for rotation and scaling. Default is (0, 0).

visible: bool

Whether the node is visible. If false, the node and its children won't be rendered.

z_index: int

The z-index for rendering order. Higher values are rendered on top.

Inherited Fields: Node2D also has all fields from Node: name, id, parent, children, script_path, is_root_of

Related