Node2D

Inherits: CanvasItem < Node < Object

Inherited By: AnimatedSprite, AudioStreamPlayer2D, BackBufferCopy, Bone2D, CPUParticles2D, Camera2D, CanvasModulate, CollisionObject2D, CollisionPolygon2D, CollisionShape2D, Joint2D, Light2D, LightOccluder2D, Line2D, MeshInstance2D, MultiMeshInstance2D, Navigation2D, NavigationPolygonInstance, ParallaxLayer, Particles2D, Path2D, PathFollow2D, Polygon2D, Position2D, RayCast2D, RemoteTransform2D, Skeleton2D, Sprite, TileMap, TouchScreenButton, VisibilityNotifier2D, YSort

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.

Methods

voidapply_scale ( Vector2 ratio )
floatget_angle_to ( Vector2 point ) const
Transform2Dget_relative_transform_to_parent ( Node parent ) const
voidglobal_translate ( Vector2 offset )
voidlook_at ( Vector2 point )
voidmove_local_x ( float delta, bool scaled=false )
voidmove_local_y ( float delta, bool scaled=false )
voidrotate ( float radians )
Vector2to_global ( Vector2 local_point ) const
Vector2to_local ( Vector2 global_point ) const
voidtranslate ( Vector2 offset )

Property Descriptions

Setterset_global_position(value)
Getterget_global_position()

Global position.


Setterset_global_rotation(value)
Getterget_global_rotation()

Global rotation in radians.


  • float global_rotation_degrees
Setterset_global_rotation_degrees(value)
Getterget_global_rotation_degrees()

Global rotation in degrees.


Setterset_global_scale(value)
Getterget_global_scale()

Global scale.


Setterset_global_transform(value)
Getterget_global_transform()

Global Transform2D.


DefaultVector2( 0, 0 )
Setterset_position(value)
Getterget_position()

Position, relative to the node’s parent.


Default0.0
Setterset_rotation(value)
Getterget_rotation()

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


Default0.0
Setterset_rotation_degrees(value)
Getterget_rotation_degrees()

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


DefaultVector2( 1, 1 )
Setterset_scale(value)
Getterget_scale()

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


Setterset_transform(value)
Getterget_transform()

Local Transform2D.


Defaulttrue
Setterset_z_as_relative(value)
Getteris_z_relative()

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.


Default0
Setterset_z_index(value)
Getterget_z_index()

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

Method Descriptions

Multiplies the current scale by the ratio vector.


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


Returns the Transform2D relative to this node’s parent.


  • void global_translate ( Vector2 offset )

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


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


  • void move_local_x ( float delta, bool scaled=false )

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


  • void move_local_y ( float delta, bool scaled=false )

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


  • void rotate ( float radians )

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


Converts a local point’s coordinates to global coordinates.


Converts a global point’s coordinates to local coordinates.


Translates the node by the given offset in local coordinates.

Doc ID missing

Disclaimer: This page has been automaticaly and directly extracted from the official Godot Docs website, the 1970-01-01 at 00:00:00. It’s the English Stable version because it’s what most Godot users should use. The Copyright owners are Juan Linietsky, Ariel Manzur and the Godot community. CC-BY 3.0. Thanks for your patience and generosity.