Node2D.xml 6.0 KB

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