Node2D.xml 5.8 KB

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