class_bone2d.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Bone2D.xml.
  6. .. _class_Bone2D:
  7. Bone2D
  8. ======
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A joint used with :ref:`Skeleton2D<class_Skeleton2D>` to control and animate other nodes.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A hierarchy of **Bone2D**\ s can be bound to a :ref:`Skeleton2D<class_Skeleton2D>` to control and animate other :ref:`Node2D<class_Node2D>` nodes.
  15. You can use **Bone2D** and :ref:`Skeleton2D<class_Skeleton2D>` nodes to animate 2D meshes created with the :ref:`Polygon2D<class_Polygon2D>` UV editor.
  16. Each bone has a :ref:`rest<class_Bone2D_property_rest>` transform that you can reset to with :ref:`apply_rest<class_Bone2D_method_apply_rest>`. These rest poses are relative to the bone's parent.
  17. If in the editor, you can set the rest pose of an entire skeleton using a menu option, from the code, you need to iterate over the bones to set their individual rest poses.
  18. .. rst-class:: classref-reftable-group
  19. Properties
  20. ----------
  21. .. table::
  22. :widths: auto
  23. +---------------------------------------+-----------------------------------------+-----------------------------------+
  24. | :ref:`Transform2D<class_Transform2D>` | :ref:`rest<class_Bone2D_property_rest>` | ``Transform2D(0, 0, 0, 0, 0, 0)`` |
  25. +---------------------------------------+-----------------------------------------+-----------------------------------+
  26. .. rst-class:: classref-reftable-group
  27. Methods
  28. -------
  29. .. table::
  30. :widths: auto
  31. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | |void| | :ref:`apply_rest<class_Bone2D_method_apply_rest>`\ (\ ) |
  33. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`get_autocalculate_length_and_angle<class_Bone2D_method_get_autocalculate_length_and_angle>`\ (\ ) |const| |
  35. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`get_bone_angle<class_Bone2D_method_get_bone_angle>`\ (\ ) |const| |
  37. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_index_in_skeleton<class_Bone2D_method_get_index_in_skeleton>`\ (\ ) |const| |
  39. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`get_length<class_Bone2D_method_get_length>`\ (\ ) |const| |
  41. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_skeleton_rest<class_Bone2D_method_get_skeleton_rest>`\ (\ ) |const| |
  43. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | |void| | :ref:`set_autocalculate_length_and_angle<class_Bone2D_method_set_autocalculate_length_and_angle>`\ (\ auto_calculate\: :ref:`bool<class_bool>`\ ) |
  45. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | |void| | :ref:`set_bone_angle<class_Bone2D_method_set_bone_angle>`\ (\ angle\: :ref:`float<class_float>`\ ) |
  47. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | |void| | :ref:`set_length<class_Bone2D_method_set_length>`\ (\ length\: :ref:`float<class_float>`\ ) |
  49. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  50. .. rst-class:: classref-section-separator
  51. ----
  52. .. rst-class:: classref-descriptions-group
  53. Property Descriptions
  54. ---------------------
  55. .. _class_Bone2D_property_rest:
  56. .. rst-class:: classref-property
  57. :ref:`Transform2D<class_Transform2D>` **rest** = ``Transform2D(0, 0, 0, 0, 0, 0)`` :ref:`🔗<class_Bone2D_property_rest>`
  58. .. rst-class:: classref-property-setget
  59. - |void| **set_rest**\ (\ value\: :ref:`Transform2D<class_Transform2D>`\ )
  60. - :ref:`Transform2D<class_Transform2D>` **get_rest**\ (\ )
  61. Rest transform of the bone. You can reset the node's transforms to this value using :ref:`apply_rest<class_Bone2D_method_apply_rest>`.
  62. .. rst-class:: classref-section-separator
  63. ----
  64. .. rst-class:: classref-descriptions-group
  65. Method Descriptions
  66. -------------------
  67. .. _class_Bone2D_method_apply_rest:
  68. .. rst-class:: classref-method
  69. |void| **apply_rest**\ (\ ) :ref:`🔗<class_Bone2D_method_apply_rest>`
  70. Resets the bone to the rest pose. This is equivalent to setting :ref:`Node2D.transform<class_Node2D_property_transform>` to :ref:`rest<class_Bone2D_property_rest>`.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_Bone2D_method_get_autocalculate_length_and_angle:
  74. .. rst-class:: classref-method
  75. :ref:`bool<class_bool>` **get_autocalculate_length_and_angle**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_autocalculate_length_and_angle>`
  76. Returns whether this **Bone2D** is going to autocalculate its length and bone angle using its first **Bone2D** child node, if one exists. If there are no **Bone2D** children, then it cannot autocalculate these values and will print a warning.
  77. .. rst-class:: classref-item-separator
  78. ----
  79. .. _class_Bone2D_method_get_bone_angle:
  80. .. rst-class:: classref-method
  81. :ref:`float<class_float>` **get_bone_angle**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_bone_angle>`
  82. Returns the angle of the bone in the **Bone2D**.
  83. \ **Note:** This is different from the **Bone2D**'s rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the **Bone2D**'s :ref:`Node2D.transform<class_Node2D_property_transform>`.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_Bone2D_method_get_index_in_skeleton:
  87. .. rst-class:: classref-method
  88. :ref:`int<class_int>` **get_index_in_skeleton**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_index_in_skeleton>`
  89. Returns the node's index as part of the entire skeleton. See :ref:`Skeleton2D<class_Skeleton2D>`.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_Bone2D_method_get_length:
  93. .. rst-class:: classref-method
  94. :ref:`float<class_float>` **get_length**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_length>`
  95. Returns the length of the bone in the **Bone2D** node.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_Bone2D_method_get_skeleton_rest:
  99. .. rst-class:: classref-method
  100. :ref:`Transform2D<class_Transform2D>` **get_skeleton_rest**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_skeleton_rest>`
  101. Returns the node's :ref:`rest<class_Bone2D_property_rest>` :ref:`Transform2D<class_Transform2D>` if it doesn't have a parent, or its rest pose relative to its parent.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_Bone2D_method_set_autocalculate_length_and_angle:
  105. .. rst-class:: classref-method
  106. |void| **set_autocalculate_length_and_angle**\ (\ auto_calculate\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Bone2D_method_set_autocalculate_length_and_angle>`
  107. When set to ``true``, the **Bone2D** node will attempt to automatically calculate the bone angle and length using the first child **Bone2D** node, if one exists. If none exist, the **Bone2D** cannot automatically calculate these values and will print a warning.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_Bone2D_method_set_bone_angle:
  111. .. rst-class:: classref-method
  112. |void| **set_bone_angle**\ (\ angle\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Bone2D_method_set_bone_angle>`
  113. Sets the bone angle for the **Bone2D**. This is typically set to the rotation from the **Bone2D** to a child **Bone2D** node.
  114. \ **Note:** This is different from the **Bone2D**'s rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the **Bone2D**'s :ref:`Node2D.transform<class_Node2D_property_transform>`.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_Bone2D_method_set_length:
  118. .. rst-class:: classref-method
  119. |void| **set_length**\ (\ length\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Bone2D_method_set_length>`
  120. Sets the length of the bone in the **Bone2D**.
  121. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  122. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  123. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  124. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  125. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  126. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  127. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  128. .. |void| replace:: :abbr:`void (No return value.)`