2
0

Node2D.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Node2D" inherits="CanvasItem" version="3.3">
  3. <brief_description>
  4. A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
  5. </brief_description>
  6. <description>
  7. 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.
  8. </description>
  9. <tutorials>
  10. <link title="Custom drawing in 2D">https://docs.godotengine.org/en/3.3/tutorials/2d/custom_drawing_in_2d.html</link>
  11. <link title="All 2D Demos">https://github.com/godotengine/godot-demo-projects/tree/master/2d</link>
  12. </tutorials>
  13. <methods>
  14. <method name="apply_scale">
  15. <return type="void">
  16. </return>
  17. <argument index="0" name="ratio" type="Vector2">
  18. </argument>
  19. <description>
  20. Multiplies the current scale by the [code]ratio[/code] vector.
  21. </description>
  22. </method>
  23. <method name="get_angle_to" qualifiers="const">
  24. <return type="float">
  25. </return>
  26. <argument index="0" name="point" type="Vector2">
  27. </argument>
  28. <description>
  29. Returns the angle between the node and the [code]point[/code] in radians.
  30. </description>
  31. </method>
  32. <method name="get_relative_transform_to_parent" qualifiers="const">
  33. <return type="Transform2D">
  34. </return>
  35. <argument index="0" name="parent" type="Node">
  36. </argument>
  37. <description>
  38. Returns the [Transform2D] relative to this node's parent.
  39. </description>
  40. </method>
  41. <method name="global_translate">
  42. <return type="void">
  43. </return>
  44. <argument index="0" name="offset" type="Vector2">
  45. </argument>
  46. <description>
  47. Adds the [code]offset[/code] vector to the node's global position.
  48. </description>
  49. </method>
  50. <method name="look_at">
  51. <return type="void">
  52. </return>
  53. <argument index="0" name="point" type="Vector2">
  54. </argument>
  55. <description>
  56. Rotates the node so it points towards the [code]point[/code], which is expected to use global coordinates.
  57. </description>
  58. </method>
  59. <method name="move_local_x">
  60. <return type="void">
  61. </return>
  62. <argument index="0" name="delta" type="float">
  63. </argument>
  64. <argument index="1" name="scaled" type="bool" default="false">
  65. </argument>
  66. <description>
  67. Applies a local translation on the node's X axis based on the [method Node._process]'s [code]delta[/code]. If [code]scaled[/code] is [code]false[/code], normalizes the movement.
  68. </description>
  69. </method>
  70. <method name="move_local_y">
  71. <return type="void">
  72. </return>
  73. <argument index="0" name="delta" type="float">
  74. </argument>
  75. <argument index="1" name="scaled" type="bool" default="false">
  76. </argument>
  77. <description>
  78. Applies a local translation on the node's Y axis based on the [method Node._process]'s [code]delta[/code]. If [code]scaled[/code] is [code]false[/code], normalizes the movement.
  79. </description>
  80. </method>
  81. <method name="rotate">
  82. <return type="void">
  83. </return>
  84. <argument index="0" name="radians" type="float">
  85. </argument>
  86. <description>
  87. Applies a rotation to the node, in radians, starting from its current rotation.
  88. </description>
  89. </method>
  90. <method name="to_global" qualifiers="const">
  91. <return type="Vector2">
  92. </return>
  93. <argument index="0" name="local_point" type="Vector2">
  94. </argument>
  95. <description>
  96. 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.
  97. </description>
  98. </method>
  99. <method name="to_local" qualifiers="const">
  100. <return type="Vector2">
  101. </return>
  102. <argument index="0" name="global_point" type="Vector2">
  103. </argument>
  104. <description>
  105. 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.
  106. </description>
  107. </method>
  108. <method name="translate">
  109. <return type="void">
  110. </return>
  111. <argument index="0" name="offset" type="Vector2">
  112. </argument>
  113. <description>
  114. Translates the node by the given [code]offset[/code] in local coordinates.
  115. </description>
  116. </method>
  117. </methods>
  118. <members>
  119. <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position">
  120. Global position.
  121. </member>
  122. <member name="global_rotation" type="float" setter="set_global_rotation" getter="get_global_rotation">
  123. Global rotation in radians.
  124. </member>
  125. <member name="global_rotation_degrees" type="float" setter="set_global_rotation_degrees" getter="get_global_rotation_degrees">
  126. Global rotation in degrees.
  127. </member>
  128. <member name="global_scale" type="Vector2" setter="set_global_scale" getter="get_global_scale">
  129. Global scale.
  130. </member>
  131. <member name="global_transform" type="Transform2D" setter="set_global_transform" getter="get_global_transform">
  132. Global [Transform2D].
  133. </member>
  134. <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )">
  135. Position, relative to the node's parent.
  136. </member>
  137. <member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
  138. Rotation in radians, relative to the node's parent.
  139. </member>
  140. <member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0">
  141. Rotation in degrees, relative to the node's parent.
  142. </member>
  143. <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )">
  144. The node's scale. Unscaled value: [code](1, 1)[/code].
  145. </member>
  146. <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform">
  147. Local [Transform2D].
  148. </member>
  149. <member name="z_as_relative" type="bool" setter="set_z_as_relative" getter="is_z_relative" default="true">
  150. If [code]true[/code], 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.
  151. </member>
  152. <member name="z_index" type="int" setter="set_z_index" getter="get_z_index" default="0">
  153. Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others.
  154. </member>
  155. </members>
  156. <constants>
  157. </constants>
  158. </class>