Node2D.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. <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. </description>
  27. </method>
  28. <method name="get_relative_transform_to_parent" qualifiers="const">
  29. <return type="Transform2D" />
  30. <argument index="0" name="parent" type="Node" />
  31. <description>
  32. Returns the [Transform2D] relative to this node's parent.
  33. </description>
  34. </method>
  35. <method name="global_translate">
  36. <return type="void" />
  37. <argument index="0" name="offset" type="Vector2" />
  38. <description>
  39. Adds the [code]offset[/code] vector to the node's global position.
  40. </description>
  41. </method>
  42. <method name="look_at">
  43. <return type="void" />
  44. <argument index="0" name="point" type="Vector2" />
  45. <description>
  46. Rotates the node so it points towards the [code]point[/code], which is expected to use global coordinates.
  47. </description>
  48. </method>
  49. <method name="move_local_x">
  50. <return type="void" />
  51. <argument index="0" name="delta" type="float" />
  52. <argument index="1" name="scaled" type="bool" default="false" />
  53. <description>
  54. 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.
  55. </description>
  56. </method>
  57. <method name="move_local_y">
  58. <return type="void" />
  59. <argument index="0" name="delta" type="float" />
  60. <argument index="1" name="scaled" type="bool" default="false" />
  61. <description>
  62. 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.
  63. </description>
  64. </method>
  65. <method name="rotate">
  66. <return type="void" />
  67. <argument index="0" name="radians" type="float" />
  68. <description>
  69. Applies a rotation to the node, in radians, starting from its current rotation.
  70. </description>
  71. </method>
  72. <method name="to_global" qualifiers="const">
  73. <return type="Vector2" />
  74. <argument index="0" name="local_point" type="Vector2" />
  75. <description>
  76. 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.
  77. </description>
  78. </method>
  79. <method name="to_local" qualifiers="const">
  80. <return type="Vector2" />
  81. <argument index="0" name="global_point" type="Vector2" />
  82. <description>
  83. 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.
  84. </description>
  85. </method>
  86. <method name="translate">
  87. <return type="void" />
  88. <argument index="0" name="offset" type="Vector2" />
  89. <description>
  90. Translates the node by the given [code]offset[/code] in local coordinates.
  91. </description>
  92. </method>
  93. </methods>
  94. <members>
  95. <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position">
  96. Global position.
  97. </member>
  98. <member name="global_rotation" type="float" setter="set_global_rotation" getter="get_global_rotation">
  99. Global rotation in radians.
  100. </member>
  101. <member name="global_rotation_degrees" type="float" setter="set_global_rotation_degrees" getter="get_global_rotation_degrees">
  102. Global rotation in degrees.
  103. </member>
  104. <member name="global_scale" type="Vector2" setter="set_global_scale" getter="get_global_scale">
  105. Global scale.
  106. </member>
  107. <member name="global_transform" type="Transform2D" setter="set_global_transform" getter="get_global_transform">
  108. Global [Transform2D].
  109. </member>
  110. <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )">
  111. Position, relative to the node's parent.
  112. </member>
  113. <member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
  114. Rotation in radians, relative to the node's parent.
  115. </member>
  116. <member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0">
  117. Rotation in degrees, relative to the node's parent.
  118. </member>
  119. <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )">
  120. The node's scale. Unscaled value: [code](1, 1)[/code].
  121. </member>
  122. <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform">
  123. Local [Transform2D].
  124. </member>
  125. <member name="z_as_relative" type="bool" setter="set_z_as_relative" getter="is_z_relative" default="true">
  126. 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.
  127. </member>
  128. <member name="z_index" type="int" setter="set_z_index" getter="get_z_index" default="0">
  129. 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).
  130. </member>
  131. </members>
  132. <constants>
  133. </constants>
  134. </class>