.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Node2D.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Node2D: Node2D ====== **Inherits:** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` **Inherited By:** :ref:`RemoteTransform2D`, :ref:`Joint2D`, :ref:`VisibilityNotifier2D`, :ref:`Navigation2D`, :ref:`CollisionPolygon2D`, :ref:`TouchScreenButton`, :ref:`Particles2D`, :ref:`AnimatedSprite`, :ref:`RayCast2D`, :ref:`Light2D`, :ref:`Path2D`, :ref:`Line2D`, :ref:`Position2D`, :ref:`AudioStreamPlayer2D`, :ref:`CanvasModulate`, :ref:`Sprite`, :ref:`CollisionShape2D`, :ref:`NavigationPolygonInstance`, :ref:`PathFollow2D`, :ref:`ParallaxLayer`, :ref:`Polygon2D`, :ref:`LightOccluder2D`, :ref:`CollisionObject2D`, :ref:`BackBufferCopy`, :ref:`YSort`, :ref:`TileMap`, :ref:`Camera2D` **Category:** Core Brief Description ----------------- A 2D game object, parent of all 2D related nodes. Has a position, rotation, scale and Z-index. Member Functions ---------------- +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`apply_scale` **(** :ref:`Vector2` ratio **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`edit_set_pivot` **(** :ref:`Vector2` pivot **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_angle_to` **(** :ref:`Vector2` point **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_global_position` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_global_rotation` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_global_rotation_in_degrees` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_global_scale` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_position` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform2D` | :ref:`get_relative_transform_to_parent` **(** :ref:`Node` parent **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_rotation` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_rotation_in_degrees` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_scale` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_z` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`global_translate` **(** :ref:`Vector2` offset **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_z_relative` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`look_at` **(** :ref:`Vector2` point **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`move_local_x` **(** :ref:`float` delta, :ref:`bool` scaled=false **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`move_local_y` **(** :ref:`float` delta, :ref:`bool` scaled=false **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`rotate` **(** :ref:`float` radians **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_global_position` **(** :ref:`Vector2` position **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_global_rotation` **(** :ref:`float` radians **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_global_rotation_in_degrees` **(** :ref:`float` degrees **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_global_scale` **(** :ref:`Vector2` scale **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_global_transform` **(** :ref:`Transform2D` xform **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_position` **(** :ref:`Vector2` position **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_rotation` **(** :ref:`float` radians **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_rotation_in_degrees` **(** :ref:`float` degrees **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_scale` **(** :ref:`Vector2` scale **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_transform` **(** :ref:`Transform2D` xform **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_z` **(** :ref:`int` z **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_z_as_relative` **(** :ref:`bool` enable **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`to_global` **(** :ref:`Vector2` local_point **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`to_local` **(** :ref:`Vector2` global_point **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`translate` **(** :ref:`Vector2` offset **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ Member Variables ---------------- - :ref:`Vector2` **global_position** - Global position. - :ref:`float` **global_rotation** - Global rotation in radians. - :ref:`float` **global_rotation_deg** - Global rotation in degrees. - :ref:`Vector2` **global_scale** - Global scale. - :ref:`Transform2D` **global_transform** - Global [Transform2D]. - :ref:`Vector2` **position** - Position, relative to the node's parent. - :ref:`float` **rotation** - Rotation in radians. - :ref:`float` **rotation_deg** - Rotation in degrees. - :ref:`Vector2` **scale** - Rotation in degrees. - :ref:`Transform2D` **transform** - Local [Transform2D]. - :ref:`int` **z** - Z-index. Controls the order in which the nodes render. A node with a higher Z-index will display in front of others. - :ref:`bool` **z_as_relative** - Make the node's Z-index 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. Description ----------- 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. Member Function Description --------------------------- .. _class_Node2D_apply_scale: - void **apply_scale** **(** :ref:`Vector2` ratio **)** Multiplies the current scale by the 'ratio' vector. .. _class_Node2D_edit_set_pivot: - void **edit_set_pivot** **(** :ref:`Vector2` pivot **)** Set the pivot position of the 2D node to 'pivot' value. Only some Node2Ds implement this method. .. _class_Node2D_get_angle_to: - :ref:`float` **get_angle_to** **(** :ref:`Vector2` point **)** const Returns the angle between the node and the 'point' in radians. .. _class_Node2D_get_global_position: - :ref:`Vector2` **get_global_position** **(** **)** const Returns the node's global position. .. _class_Node2D_get_global_rotation: - :ref:`float` **get_global_rotation** **(** **)** const Returns the node's global rotation in radians. .. _class_Node2D_get_global_rotation_in_degrees: - :ref:`float` **get_global_rotation_in_degrees** **(** **)** const Return the node's global rotation in degrees. .. _class_Node2D_get_global_scale: - :ref:`Vector2` **get_global_scale** **(** **)** const Returns the node's global scale. .. _class_Node2D_get_position: - :ref:`Vector2` **get_position** **(** **)** const Returns the node's position. .. _class_Node2D_get_relative_transform_to_parent: - :ref:`Transform2D` **get_relative_transform_to_parent** **(** :ref:`Node` parent **)** const Returns the :ref:`Transform2D` relative to this node's parent. .. _class_Node2D_get_rotation: - :ref:`float` **get_rotation** **(** **)** const Returns the node's rotation in radians. .. _class_Node2D_get_rotation_in_degrees: - :ref:`float` **get_rotation_in_degrees** **(** **)** const Returns the node's rotation in degrees. .. _class_Node2D_get_scale: - :ref:`Vector2` **get_scale** **(** **)** const Returns the node's scale. .. _class_Node2D_get_z: - :ref:`int` **get_z** **(** **)** const Returns the node's Z-index. .. _class_Node2D_global_translate: - void **global_translate** **(** :ref:`Vector2` offset **)** Adds the 'offset' vector to the node's global position. .. _class_Node2D_is_z_relative: - :ref:`bool` **is_z_relative** **(** **)** const Returns true if this node's Z-index is relative to its parent's. Else, returns false. .. _class_Node2D_look_at: - void **look_at** **(** :ref:`Vector2` point **)** Rotates the node so it points towards the 'point'. .. _class_Node2D_move_local_x: - void **move_local_x** **(** :ref:`float` delta, :ref:`bool` scaled=false **)** Apply a local translation on the node's X axis based on the process's 'delta'. If 'scaled' is false, normalizes the movement. .. _class_Node2D_move_local_y: - void **move_local_y** **(** :ref:`float` delta, :ref:`bool` scaled=false **)** Apply a local translation on the node's Y axis based on the process's 'delta'. If 'scaled' is false, normalizes the movement. .. _class_Node2D_rotate: - void **rotate** **(** :ref:`float` radians **)** Apply a rotation to the node, in radians, starting from its current rotation. .. _class_Node2D_set_global_position: - void **set_global_position** **(** :ref:`Vector2` position **)** Set the node's global position. .. _class_Node2D_set_global_rotation: - void **set_global_rotation** **(** :ref:`float` radians **)** Set the node's global rotation in radians. .. _class_Node2D_set_global_rotation_in_degrees: - void **set_global_rotation_in_degrees** **(** :ref:`float` degrees **)** Set the node's global rotation in degrees. .. _class_Node2D_set_global_scale: - void **set_global_scale** **(** :ref:`Vector2` scale **)** Set the node's global scale. .. _class_Node2D_set_global_transform: - void **set_global_transform** **(** :ref:`Transform2D` xform **)** Set the node's global :ref:`Transform2D`. .. _class_Node2D_set_position: - void **set_position** **(** :ref:`Vector2` position **)** Set the node's position. .. _class_Node2D_set_rotation: - void **set_rotation** **(** :ref:`float` radians **)** Set the node's rotation in radians. .. _class_Node2D_set_rotation_in_degrees: - void **set_rotation_in_degrees** **(** :ref:`float` degrees **)** Set the node's rotation in degrees. .. _class_Node2D_set_scale: - void **set_scale** **(** :ref:`Vector2` scale **)** Set the node's scale. .. _class_Node2D_set_transform: - void **set_transform** **(** :ref:`Transform2D` xform **)** Set the node's local :ref:`Transform2D`. .. _class_Node2D_set_z: - void **set_z** **(** :ref:`int` z **)** Set the node's Z-index. .. _class_Node2D_set_z_as_relative: - void **set_z_as_relative** **(** :ref:`bool` enable **)** Make the node's Z-index 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. .. _class_Node2D_to_global: - :ref:`Vector2` **to_global** **(** :ref:`Vector2` local_point **)** const .. _class_Node2D_to_local: - :ref:`Vector2` **to_local** **(** :ref:`Vector2` global_point **)** const .. _class_Node2D_translate: - void **translate** **(** :ref:`Vector2` offset **)** Translate the node locally by the 'offset' vector, starting from its current local position.