Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Node2D

Inherits: CanvasItem < Node < Object

Inherited By: AnimatedSprite2D, AudioListener2D, AudioStreamPlayer2D, BackBufferCopy, Bone2D, Camera2D, CanvasGroup, CanvasModulate, CollisionObject2D, CollisionPolygon2D, CollisionShape2D, CPUParticles2D, GPUParticles2D, Joint2D, Light2D, LightOccluder2D, Line2D, Marker2D, MeshInstance2D, MultiMeshInstance2D, NavigationLink2D, NavigationObstacle2D, NavigationRegion2D, ParallaxLayer, Path2D, PathFollow2D, Polygon2D, RayCast2D, RemoteTransform2D, ShapeCast2D, Skeleton2D, Sprite2D, TileMap, TouchScreenButton, VisibleOnScreenNotifier2D

A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.

Description

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.

Tutorials

Properties

Vector2

global_position

float

global_rotation

float

global_rotation_degrees

Vector2

global_scale

float

global_skew

Transform2D

global_transform

Vector2

position

Vector2(0, 0)

float

rotation

0.0

float

rotation_degrees

Vector2

scale

Vector2(1, 1)

float

skew

0.0

Transform2D

transform

Methods

void

apply_scale ( Vector2 ratio )

float

get_angle_to ( Vector2 point ) const

Transform2D

get_relative_transform_to_parent ( Node parent ) const

void

global_translate ( Vector2 offset )

void

look_at ( Vector2 point )

void

move_local_x ( float delta, bool scaled=false )

void

move_local_y ( float delta, bool scaled=false )