1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Node2D" inherits="CanvasItem" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
</brief_description>
<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.
</description>
<tutorials>
<link title="Custom drawing in 2D">$DOCS_URL/tutorials/2d/custom_drawing_in_2d.html</link>
<link title="All 2D Demos">https://github.com/godotengine/godot-demo-projects/tree/master/2d</link>
</tutorials>
<methods>
<method name="apply_scale">
<return type="void" />
<param index="0" name="ratio" type="Vector2" />
<description>
Multiplies the current scale by the [param ratio] vector.
</description>
</method>
<method name="get_angle_to" qualifiers="const">
<return type="float" />
<param index="0" name="point" type="Vector2" />
<description>
Returns the angle between the node and the [param point] in radians.
[url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/node2d_get_angle_to.png]Illustration of the returned angle.[/url]
</description>
</method>
<method name="get_relative_transform_to_parent" qualifiers="const">
<return type="Transform2D" />
<param index="0" name="parent" type="Node" />
<description>
Returns the [Transform2D] relative to this node's parent.
</description>
</method>
<method name="global_translate">
<return type="void" />
<param index="0" name="offset" type="Vector2" />
<description>
Adds the [param offset] vector to the node's global position.
</description>
</method>
<method name="look_at">
<return type="void" />
<param index="0" name="point" type="Vector2" />
<description>
Rotates the node so that its local +X axis points towards the [param point], which is expected to use global coordinates.
[param point] should not be the same as the node's position, otherwise the node always looks to the right.
</description>
</method>
<method name="move_local_x">
<return type="void" />
<param index="0" name="delta" type="float" />
<param index="1" name="scaled" type="bool" default="false" />
<description>
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.
</description>
</method>
<method name="move_local_y">
<return type="void" />
<param index="0" name="delta" type="float" />
<param index="1" name="scaled" type="bool" default="false" />
<description>
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.
</description>
</method>
<method name="rotate">
<return type="void" />
<param index="0" name="radians" type="float" />
<description>
Applies a rotation to the node, in radians, starting from its current rotation.
</description>
</method>
<method name="to_global" qualifiers="const">
<return type="Vector2" />
<param index="0" name="local_point" type="Vector2" />
<description>
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.
</description>
</method>
<method name="to_local" qualifiers="const">
<return type="Vector2" />
<param index="0" name="global_point" type="Vector2" />
<description>
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.
</description>
</method>
<method name="translate">
<return type="void" />
<param index="0" name="offset" type="Vector2" />
<description>
Translates the node by the given [param offset] in local coordinates.
</description>
</method>
</methods>
<members>
<member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position">
Global position. See also [member position].
</member>
<member name="global_rotation" type="float" setter="set_global_rotation" getter="get_global_rotation">
Global rotation in radians. See also [member rotation].
</member>
<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. See also [member rotation_degrees].
</member>
<member name="global_scale" type="Vector2" setter="set_global_scale" getter="get_global_scale">
Global scale. See also [member scale].
</member>
<member name="global_skew" type="float" setter="set_global_skew" getter="get_global_skew">
Global skew in radians. See also [member skew].
</member>
<member name="global_transform" type="Transform2D" setter="set_global_transform" getter="get_global_transform">
Global [Transform2D]. See also [member transform].
</member>
<member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
Position, relative to the node's parent. See also [member global_position].
</member>
<member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
Rotation in radians, relative to the node's parent. See also [member global_rotation].
[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].
</member>
<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. See also [member global_rotation_degrees].
</member>
<member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
The node's scale, relative to the node's parent. Unscaled value: [code](1, 1)[/code]. See also [member global_scale].
[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.
</member>
<member name="skew" type="float" setter="set_skew" getter="get_skew" default="0.0">
If set to a non-zero value, slants the node in one direction or another. This can be used for pseudo-3D effects. See also [member global_skew].
[b]Note:[/b] Skew is performed on the X axis only, and [i]between[/i] rotation and scaling.
[b]Note:[/b] This property is edited in the inspector in degrees. If you want to use degrees in a script, use [code]skew = deg_to_rad(value_in_degrees)[/code].
</member>
<member name="transform" type="Transform2D" setter="set_transform" getter="get_transform">
The node's [Transform2D], relative to the node's parent. See also [member global_transform].
</member>
</members>
</class>
|