2017-09-12 22:42:36 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2022-02-14 14:18:53 +01:00
<class name= "Node2D" inherits= "CanvasItem" version= "4.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 22:42:36 +02:00
<brief_description >
2019-12-26 19:24:29 +01:00
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
2017-09-12 22:42:36 +02:00
</brief_description>
<description >
2019-12-26 19:24:29 +01:00
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.
2017-09-12 22:42:36 +02:00
</description>
<tutorials >
2021-11-15 10:43:07 +01:00
<link title= "Custom drawing in 2D" > $DOCS_URL/tutorials/2d/custom_drawing_in_2d.html</link>
2020-10-01 10:34:47 +02:00
<link title= "All 2D Demos" > https://github.com/godotengine/godot-demo-projects/tree/master/2d</link>
2017-09-12 22:42:36 +02:00
</tutorials>
<methods >
<method name= "apply_scale" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "ratio" type= "Vector2" />
2017-09-12 22:42:36 +02:00
<description >
2022-08-12 15:36:48 +02:00
Multiplies the current scale by the [param ratio] vector.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "get_angle_to" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "float" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "point" type= "Vector2" />
2017-09-12 22:42:36 +02:00
<description >
2022-08-12 15:36:48 +02:00
Returns the angle between the node and the [param point] in radians.
2021-08-23 13:21:32 +02:00
[url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/node2d_get_angle_to.png]Illustration of the returned angle.[/url]
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "get_relative_transform_to_parent" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "Transform2D" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "parent" type= "Node" />
2017-09-12 22:42:36 +02:00
<description >
Returns the [Transform2D] relative to this node's parent.
</description>
</method>
<method name= "global_translate" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "offset" type= "Vector2" />
2017-09-12 22:42:36 +02:00
<description >
2022-08-12 15:36:48 +02:00
Adds the [param offset] vector to the node's global position.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "look_at" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "point" type= "Vector2" />
2017-09-12 22:42:36 +02:00
<description >
2022-08-12 15:36:48 +02:00
Rotates the node so it points towards the [param point], which is expected to use global coordinates.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "move_local_x" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "delta" type= "float" />
<param index= "1" name= "scaled" type= "bool" default= "false" />
2017-09-12 22:42:36 +02:00
<description >
2022-08-12 15:36:48 +02:00
Applies a local translation on the node's X axis based on the [method Node._process]'s [param delta]. If [param scaled] is [code]false[/code], normalizes the movement.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "move_local_y" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "delta" type= "float" />
<param index= "1" name= "scaled" type= "bool" default= "false" />
2017-09-12 22:42:36 +02:00
<description >
2022-08-12 15:36:48 +02:00
Applies a local translation on the node's Y axis based on the [method Node._process]'s [param delta]. If [param scaled] is [code]false[/code], normalizes the movement.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "rotate" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "radians" type= "float" />
2017-09-12 22:42:36 +02:00
<description >
2017-10-22 22:43:35 +02:00
Applies a rotation to the node, in radians, starting from its current rotation.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "to_global" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "Vector2" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "local_point" type= "Vector2" />
2017-09-12 22:42:36 +02:00
<description >
2020-02-24 04:38:32 +01:00
Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the [Node2D] it is called on. e.g. Applying this method to the positions of child nodes will correctly transform their positions into the global coordinate space, but applying it to a node's own position will give an incorrect result, as it will incorporate the node's own transformation into its global position.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "to_local" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "Vector2" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "global_point" type= "Vector2" />
2017-09-12 22:42:36 +02:00
<description >
2020-02-24 04:38:32 +01:00
Transforms the provided global position into a position in local coordinate space. The output will be local relative to the [Node2D] it is called on. e.g. It is appropriate for determining the positions of child nodes, but it is not appropriate for determining its own position relative to its parent.
2017-09-12 22:42:36 +02:00
</description>
</method>
<method name= "translate" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "offset" type= "Vector2" />
2017-09-12 22:42:36 +02:00
<description >
2022-08-12 15:36:48 +02:00
Translates the node by the given [param offset] in local coordinates.
2017-09-12 22:42:36 +02:00
</description>
</method>
</methods>
<members >
2019-06-29 21:22:15 +02:00
<member name= "global_position" type= "Vector2" setter= "set_global_position" getter= "get_global_position" >
2017-09-12 22:42:36 +02:00
Global position.
</member>
2019-06-29 21:22:15 +02:00
<member name= "global_rotation" type= "float" setter= "set_global_rotation" getter= "get_global_rotation" >
2017-09-12 22:42:36 +02:00
Global rotation in radians.
</member>
2022-12-18 16:58:19 +01:00
<member name= "global_rotation_degrees" type= "float" setter= "set_global_rotation_degrees" getter= "get_global_rotation_degrees" >
Helper property to access [member global_rotation] in degrees instead of radians.
</member>
2019-06-29 21:22:15 +02:00
<member name= "global_scale" type= "Vector2" setter= "set_global_scale" getter= "get_global_scale" >
2017-09-12 22:42:36 +02:00
Global scale.
</member>
2021-08-12 19:48:34 +02:00
<member name= "global_skew" type= "float" setter= "set_global_skew" getter= "get_global_skew" >
Global skew in radians.
</member>
2019-06-29 21:22:15 +02:00
<member name= "global_transform" type= "Transform2D" setter= "set_global_transform" getter= "get_global_transform" >
2017-09-12 22:42:36 +02:00
Global [Transform2D].
</member>
2019-09-24 19:45:03 +02:00
<member name= "position" type= "Vector2" setter= "set_position" getter= "get_position" default= "Vector2(0, 0)" >
2017-09-12 22:42:36 +02:00
Position, relative to the node's parent.
</member>
2019-06-29 12:38:01 +02:00
<member name= "rotation" type= "float" setter= "set_rotation" getter= "get_rotation" default= "0.0" >
2018-01-11 23:38:35 +01:00
Rotation in radians, relative to the node's parent.
2023-02-20 23:25:15 +01:00
[b]Note:[/b] This property is edited in the inspector in degrees. If you want to use degrees in a script, use [member rotation_degrees].
2018-01-11 23:38:35 +01:00
</member>
2022-12-18 16:58:19 +01:00
<member name= "rotation_degrees" type= "float" setter= "set_rotation_degrees" getter= "get_rotation_degrees" >
Helper property to access [member rotation] in degrees instead of radians.
</member>
2019-09-24 19:45:03 +02:00
<member name= "scale" type= "Vector2" setter= "set_scale" getter= "get_scale" default= "Vector2(1, 1)" >
2019-06-22 01:04:47 +02:00
The node's scale. Unscaled value: [code](1, 1)[/code].
2022-06-10 07:56:35 +02:00
[b]Note:[/b] Negative X scales in 2D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, negative scales on the X axis will be changed to negative scales on the Y axis and a rotation of 180 degrees when decomposed.
2017-09-12 22:42:36 +02:00
</member>
2020-05-04 16:55:01 +02:00
<member name= "skew" type= "float" setter= "set_skew" getter= "get_skew" default= "0.0" >
2022-10-06 10:09:54 +02:00
Slants the node.
[b]Note:[/b] Skew is X axis only.
2020-05-04 16:55:01 +02:00
</member>
2019-06-29 21:22:15 +02:00
<member name= "transform" type= "Transform2D" setter= "set_transform" getter= "get_transform" >
2017-09-12 22:42:36 +02:00
Local [Transform2D].
</member>
</members>
</class>