Node2D.xml 6.7 KB

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