Node2D

Inherits: CanvasItem < Node < Object

Inherited By: RemoteTransform2D, Joint2D, ParticleAttractor2D, CollisionObject2D, VisibilityNotifier2D, Navigation2D, CollisionPolygon2D, TouchScreenButton, Particles2D, AnimatedSprite, Light2D, SoundPlayer2D, ViewportSprite, Path2D, Sprite, RayCast2D, CollisionShape2D, NavigationPolygonInstance, PathFollow2D, ParallaxLayer, Polygon2D, LightOccluder2D, Position2D, BackBufferCopy, CanvasModulate, YSort, TileMap, Camera2D

Category: Core

Brief Description

Base node for 2D system.

Member Functions

void

edit_set_pivot ( Vector2 pivot )

float

get_angle_to ( Vector2 point ) const

Vector2

get_global_pos ( ) const

float

get_global_rot ( ) const

float

get_global_rotd ( ) const

Vector2

get_global_scale ( ) const

Vector2

get_pos ( ) const

Matrix32

get_relative_transform_to_parent ( Object parent ) const

float

get_rot ( ) const

float

get_rotd ( ) const

Vector2

get_scale ( ) const

int

get_z ( ) const

void

global_translate ( Vector2 offset )

bool

is_z_relative ( ) const

void

look_at ( Vector2 point )

void

move_local_x ( float delta, bool scaled=false )

void

move_local_y ( float delta, bool scaled=false )

void

rotate ( float radians )

void

scale ( Vector2 ratio )

void

set_global_pos ( Vector2 pos )

void

set_global_rot ( float radians )

void

set_global_rotd ( float degrees )

void

set_global_scale ( Vector2 scale )

void

set_global_transform ( Matrix32 xform )

void

set_pos ( Vector2 pos )

void

set_rot ( float radians )

void

set_rotd ( float degrees )

void

set_scale ( Vector2 scale )

void

set_transform ( Matrix32 xform )

void

set_z ( int z )

void

set_z_as_relative ( bool enable )

void

translate ( Vector2 offset )

Description

Base node for 2D system. Node2D contains a position, rotation and scale, which is used to position and animate. It can alternatively be used with a custom 2D transform (Matrix32). A tree of Node2Ds allows complex hierarchies for animation and positioning.

Member Function Description

  • void edit_set_pivot ( Vector2 pivot )

Set the pivot position of the 2D node to ‘pivot’ value. This method is implemented only in some nodes that inherit Node2D.

Return the rotation angle in radians needed for the 2d node to point at ‘point’ position.

Return the global position of the 2D node.

  • float get_global_rot ( ) const

Return the global rotation in radians of the 2D node.

  • float get_global_rotd ( ) const

Return the global rotation in degrees of the 2D node.

  • Vector2 get_global_scale ( ) const

Return the global scale of the 2D node.

Return the position of the 2D node.

Return the transform Matrix32 calculated relatively to the parent of this 2D node.

  • float get_rot ( ) const

Return the rotation of the 2D node.

  • float get_rotd ( ) const

Return the scale of the 2D node.

  • int get_z ( ) const

Return the Z-index of the 2D node.

  • void global_translate ( Vector2 offset )

Apply a global translation of ‘offset’ to the 2D node, starting from its current global position.

  • bool is_z_relative ( ) const

Return true if the Z-index value of this 2D node is relative to its parent’s. Else, return false.

Rotate the 2d node so it points at ‘point’ position.

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

Apply a local translation on X axis to the 2D node according to the ‘delta’ of the process. If ‘scaled’ is false, the movement is normalized.

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

Apply a local translation on Y axis to the 2D node according to the ‘delta’ of the process. If ‘scaled’ is false, the movement is normalized.

  • void rotate ( float radians )

Apply a ‘radians’ rotation to the 2D node, starting from its current rotation.

Apply the ‘ratio’ scale to the 2D node, according to its current scale value.

  • void set_global_pos ( Vector2 pos )

Set the global position of the 2D node to ‘pos’.

  • void set_global_rot ( float radians )

Set the global rotation in radians of the 2D node.

  • void set_global_rotd ( float degrees )

Set the global rotation in degrees of the 2D node.

  • void set_global_scale ( Vector2 scale )

Set the global scale of the 2D node.

  • void set_global_transform ( Matrix32 xform )

Set the global transform Matrix32 of the 2D node.

Set the position of the 2D node.

  • void set_rot ( float radians )

Set the rotation of the 2D node.

  • void set_rotd ( float degrees )

Set the rotation of the 2D node.

Set the scale of the 2D node.

Set the local transform Matrix32 of the 2D node.

  • void set_z ( int z )

Set the Z-index value of the 2D node.

  • void set_z_as_relative ( bool enable )

Set the Z-index value as relative to the parent node of this 2D node. Thus, if this 2D node’s Z-index value is 2 and its parent’s effective Z-index is 3, then the effective Z-index value of this 2D node would be 3 + 2 = 5.

  • void translate ( Vector2 offset )

Apply a local translation of ‘offset’ to the 2D node, starting from its current local position.