class_node2d.rst 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Node2D.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Node2D:
  5. Node2D
  6. ======
  7. **Inherits:** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Inherited By:** :ref:`RemoteTransform2D<class_remotetransform2d>`, :ref:`Joint2D<class_joint2d>`, :ref:`VisibilityNotifier2D<class_visibilitynotifier2d>`, :ref:`Navigation2D<class_navigation2d>`, :ref:`CollisionPolygon2D<class_collisionpolygon2d>`, :ref:`TouchScreenButton<class_touchscreenbutton>`, :ref:`Particles2D<class_particles2d>`, :ref:`AnimatedSprite<class_animatedsprite>`, :ref:`RayCast2D<class_raycast2d>`, :ref:`Light2D<class_light2d>`, :ref:`Path2D<class_path2d>`, :ref:`Line2D<class_line2d>`, :ref:`AudioStreamPlayer2D<class_audiostreamplayer2d>`, :ref:`CanvasModulate<class_canvasmodulate>`, :ref:`Sprite<class_sprite>`, :ref:`CollisionShape2D<class_collisionshape2d>`, :ref:`NavigationPolygonInstance<class_navigationpolygoninstance>`, :ref:`PathFollow2D<class_pathfollow2d>`, :ref:`ParallaxLayer<class_parallaxlayer>`, :ref:`Polygon2D<class_polygon2d>`, :ref:`Position2D<class_position2d>`, :ref:`LightOccluder2D<class_lightoccluder2d>`, :ref:`CollisionObject2D<class_collisionobject2d>`, :ref:`BackBufferCopy<class_backbuffercopy>`, :ref:`YSort<class_ysort>`, :ref:`TileMap<class_tilemap>`, :ref:`Camera2D<class_camera2d>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A 2D game object, parent of all 2D related nodes. Has a position, rotation, scale and Z-index.
  13. Member Functions
  14. ----------------
  15. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`apply_scale<class_Node2D_apply_scale>` **(** :ref:`Vector2<class_vector2>` ratio **)** |
  17. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`float<class_float>` | :ref:`get_angle_to<class_Node2D_get_angle_to>` **(** :ref:`Vector2<class_vector2>` point **)** const |
  19. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Transform2D<class_transform2d>` | :ref:`get_relative_transform_to_parent<class_Node2D_get_relative_transform_to_parent>` **(** :ref:`Node<class_node>` parent **)** const |
  21. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`global_translate<class_Node2D_global_translate>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  23. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`look_at<class_Node2D_look_at>` **(** :ref:`Vector2<class_vector2>` point **)** |
  25. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`move_local_x<class_Node2D_move_local_x>` **(** :ref:`float<class_float>` delta, :ref:`bool<class_bool>` scaled=false **)** |
  27. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`move_local_y<class_Node2D_move_local_y>` **(** :ref:`float<class_float>` delta, :ref:`bool<class_bool>` scaled=false **)** |
  29. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`rotate<class_Node2D_rotate>` **(** :ref:`float<class_float>` radians **)** |
  31. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Vector2<class_vector2>` | :ref:`to_global<class_Node2D_to_global>` **(** :ref:`Vector2<class_vector2>` local_point **)** const |
  33. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Vector2<class_vector2>` | :ref:`to_local<class_Node2D_to_local>` **(** :ref:`Vector2<class_vector2>` global_point **)** const |
  35. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`translate<class_Node2D_translate>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  37. +----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  38. Member Variables
  39. ----------------
  40. .. _class_Node2D_global_position:
  41. - :ref:`Vector2<class_vector2>` **global_position** - Global position.
  42. .. _class_Node2D_global_rotation:
  43. - :ref:`float<class_float>` **global_rotation** - Global rotation in radians.
  44. .. _class_Node2D_global_rotation_degrees:
  45. - :ref:`float<class_float>` **global_rotation_degrees** - Global rotation in degrees.
  46. .. _class_Node2D_global_scale:
  47. - :ref:`Vector2<class_vector2>` **global_scale** - Global scale.
  48. .. _class_Node2D_global_transform:
  49. - :ref:`Transform2D<class_transform2d>` **global_transform** - Global :ref:`Transform2D<class_transform2d>`.
  50. .. _class_Node2D_position:
  51. - :ref:`Vector2<class_vector2>` **position** - Position, relative to the node's parent.
  52. .. _class_Node2D_rotation:
  53. - :ref:`float<class_float>` **rotation** - Rotation in radians, relative to the node's parent.
  54. .. _class_Node2D_rotation_degrees:
  55. - :ref:`float<class_float>` **rotation_degrees** - Rotation in degrees, relative to the node's parent.
  56. .. _class_Node2D_scale:
  57. - :ref:`Vector2<class_vector2>` **scale** - The node's scale. Unscaled value: ``(1, 1)``
  58. .. _class_Node2D_transform:
  59. - :ref:`Transform2D<class_transform2d>` **transform** - Local :ref:`Transform2D<class_transform2d>`.
  60. .. _class_Node2D_z_as_relative:
  61. - :ref:`bool<class_bool>` **z_as_relative** - If ``true`` 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.
  62. .. _class_Node2D_z_index:
  63. - :ref:`int<class_int>` **z_index** - Z-index. Controls the order in which the nodes render. A node with a higher Z-index will display in front of others.
  64. Description
  65. -----------
  66. 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.
  67. Member Function Description
  68. ---------------------------
  69. .. _class_Node2D_apply_scale:
  70. - void **apply_scale** **(** :ref:`Vector2<class_vector2>` ratio **)**
  71. Multiplies the current scale by the 'ratio' vector.
  72. .. _class_Node2D_get_angle_to:
  73. - :ref:`float<class_float>` **get_angle_to** **(** :ref:`Vector2<class_vector2>` point **)** const
  74. Returns the angle between the node and the 'point' in radians.
  75. .. _class_Node2D_get_relative_transform_to_parent:
  76. - :ref:`Transform2D<class_transform2d>` **get_relative_transform_to_parent** **(** :ref:`Node<class_node>` parent **)** const
  77. Returns the :ref:`Transform2D<class_transform2d>` relative to this node's parent.
  78. .. _class_Node2D_global_translate:
  79. - void **global_translate** **(** :ref:`Vector2<class_vector2>` offset **)**
  80. Adds the 'offset' vector to the node's global position.
  81. .. _class_Node2D_look_at:
  82. - void **look_at** **(** :ref:`Vector2<class_vector2>` point **)**
  83. Rotates the node so it points towards the 'point'.
  84. .. _class_Node2D_move_local_x:
  85. - void **move_local_x** **(** :ref:`float<class_float>` delta, :ref:`bool<class_bool>` scaled=false **)**
  86. Applies a local translation on the node's X axis based on the :ref:`Node._process<class_Node__process>`'s ``delta``. If ``scaled`` is false, normalizes the movement.
  87. .. _class_Node2D_move_local_y:
  88. - void **move_local_y** **(** :ref:`float<class_float>` delta, :ref:`bool<class_bool>` scaled=false **)**
  89. Applies a local translation on the node's Y axis based on the :ref:`Node._process<class_Node__process>`'s ``delta``. If ``scaled`` is false, normalizes the movement.
  90. .. _class_Node2D_rotate:
  91. - void **rotate** **(** :ref:`float<class_float>` radians **)**
  92. Applies a rotation to the node, in radians, starting from its current rotation.
  93. .. _class_Node2D_to_global:
  94. - :ref:`Vector2<class_vector2>` **to_global** **(** :ref:`Vector2<class_vector2>` local_point **)** const
  95. Converts a local point's coordinates to global coordinates.
  96. .. _class_Node2D_to_local:
  97. - :ref:`Vector2<class_vector2>` **to_local** **(** :ref:`Vector2<class_vector2>` global_point **)** const
  98. Converts a global point's coordinates to local coordinates.
  99. .. _class_Node2D_translate:
  100. - void **translate** **(** :ref:`Vector2<class_vector2>` offset **)**
  101. Translates the node by the given ``offset`` in local coordinates.