mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
213 lines
10 KiB
ReStructuredText
213 lines
10 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. _class_Bone2D:
|
|
|
|
Bone2D
|
|
======
|
|
|
|
**繼承:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
與 :ref:`Skeleton2D<class_Skeleton2D>` 一起使用的關節,能夠控制並動畫其他節點。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
說明
|
|
----
|
|
|
|
**Bone2D** 層級結構可以綁定到 :ref:`Skeleton2D<class_Skeleton2D>` 上,控制並動畫其他 :ref:`Node2D<class_Node2D>` 節點。
|
|
|
|
你可以使用 **Bone2D** 和 :ref:`Skeleton2D<class_Skeleton2D>` 節點對使用 :ref:`Polygon2D<class_Polygon2D>` UV 編輯器建立的 2D 網格進行動畫。
|
|
|
|
每個骨骼都有一個 :ref:`rest<class_Bone2D_property_rest>` 變換,你可以用 :ref:`apply_rest()<class_Bone2D_method_apply_rest>` 來重設到這個變換。這些放鬆姿勢是相對於骨骼的父節點而言的。
|
|
|
|
如果在編輯器中,你可以使用功能表選項設定整個骨架的放鬆姿勢,從程式碼中,你需要遍曆骨骼來設定它們各自的放鬆姿勢。
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
屬性
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------------+-----------------------------------------+-----------------------------------+
|
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`rest<class_Bone2D_property_rest>` | ``Transform2D(0, 0, 0, 0, 0, 0)`` |
|
|
+---------------------------------------+-----------------------------------------+-----------------------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
方法
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`apply_rest<class_Bone2D_method_apply_rest>`\ (\ ) |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`get_autocalculate_length_and_angle<class_Bone2D_method_get_autocalculate_length_and_angle>`\ (\ ) |const| |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_bone_angle<class_Bone2D_method_get_bone_angle>`\ (\ ) |const| |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_index_in_skeleton<class_Bone2D_method_get_index_in_skeleton>`\ (\ ) |const| |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_length<class_Bone2D_method_get_length>`\ (\ ) |const| |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`get_skeleton_rest<class_Bone2D_method_get_skeleton_rest>`\ (\ ) |const| |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_autocalculate_length_and_angle<class_Bone2D_method_set_autocalculate_length_and_angle>`\ (\ auto_calculate\: :ref:`bool<class_bool>`\ ) |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_bone_angle<class_Bone2D_method_set_bone_angle>`\ (\ angle\: :ref:`float<class_float>`\ ) |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_length<class_Bone2D_method_set_length>`\ (\ length\: :ref:`float<class_float>`\ ) |
|
|
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
屬性說明
|
|
--------
|
|
|
|
.. _class_Bone2D_property_rest:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **rest** = ``Transform2D(0, 0, 0, 0, 0, 0)`` :ref:`🔗<class_Bone2D_property_rest>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_rest**\ (\ value\: :ref:`Transform2D<class_Transform2D>`\ )
|
|
- :ref:`Transform2D<class_Transform2D>` **get_rest**\ (\ )
|
|
|
|
骨骼的放鬆變換。你可以使用 :ref:`apply_rest()<class_Bone2D_method_apply_rest>` 將節點的變換重設為這個值。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
方法說明
|
|
--------
|
|
|
|
.. _class_Bone2D_method_apply_rest:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **apply_rest**\ (\ ) :ref:`🔗<class_Bone2D_method_apply_rest>`
|
|
|
|
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>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Bone2D_method_get_autocalculate_length_and_angle:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **get_autocalculate_length_and_angle**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_autocalculate_length_and_angle>`
|
|
|
|
如果該 **Bone2D** 存在骨骼子節點,則返回是否要使用第一個 **Bone2D** 子節點自動計算其長度和骨骼角度。如果沒有 **Bone2D** 子節點,則無法自動計算這些值,會列印一條警告。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Bone2D_method_get_bone_angle:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_bone_angle**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_bone_angle>`
|
|
|
|
返回 **Bone2D** 中骨骼的角度。
|
|
|
|
\ **注意:**\ 這與 **Bone2D** 的旋轉不同。骨骼角度是小工具顯示的骨骼旋轉,不受 **Bone2D** 的 :ref:`Node2D.transform<class_Node2D_property_transform>` 的影響。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Bone2D_method_get_index_in_skeleton:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_index_in_skeleton**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_index_in_skeleton>`
|
|
|
|
返回節點在整個骨架中的索引號。見 :ref:`Skeleton2D<class_Skeleton2D>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Bone2D_method_get_length:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`float<class_float>` **get_length**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_length>`
|
|
|
|
返回 **Bone2D** 節點中骨骼的長度。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Bone2D_method_get_skeleton_rest:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **get_skeleton_rest**\ (\ ) |const| :ref:`🔗<class_Bone2D_method_get_skeleton_rest>`
|
|
|
|
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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Bone2D_method_set_autocalculate_length_and_angle:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_autocalculate_length_and_angle**\ (\ auto_calculate\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Bone2D_method_set_autocalculate_length_and_angle>`
|
|
|
|
當設定為 ``true`` 時,該 **Bone2D** 節點將嘗試使用第一個子 **Bone2D** 節點(如果存在)自動計算骨骼角度和長度。如果不存在子節點,\ **Bone2D** 將無法自動計算這些值,並將輸出一條警告。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Bone2D_method_set_bone_angle:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_bone_angle**\ (\ angle\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Bone2D_method_set_bone_angle>`
|
|
|
|
設定 **Bone2D** 節點的骨骼角度。這通常設定為從 **Bone2D** 節點到子 **Bone2D** 節點的旋轉。
|
|
|
|
\ **注意:**\ 這與 **Bone2D** 的旋轉不同。骨骼角度是 **Bone2D** 小工具顯示的骨骼旋轉,不受 **Bone2D** 的 :ref:`Node2D.transform<class_Node2D_property_transform>` 的影響。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_Bone2D_method_set_length:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_length**\ (\ length\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Bone2D_method_set_length>`
|
|
|
|
設定該 **Bone2D** 中骨骼的長度。
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (本方法通常需要使用者覆寫才能生效。)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |const| replace:: :abbr:`const (本方法沒有副作用。不會修改該實例的任何成員變數。)`
|
|
.. |vararg| replace:: :abbr:`vararg (本方法除了這裡描述的參數外,還可以接受任意數量的參數。)`
|
|
.. |constructor| replace:: :abbr:`constructor (本方法用於建構一個型別。)`
|
|
.. |static| replace:: :abbr:`static (本方法無需實例即可呼叫,因此可以直接使用類別名稱呼叫。)`
|
|
.. |operator| replace:: :abbr:`operator (本方法描述將本型別作為左運算元時可用的有效運算子。)`
|
|
.. |bitfield| replace:: :abbr:`BitField (此值是由下列旗標組成的位元遮罩整數。)`
|
|
.. |void| replace:: :abbr:`void (無回傳值。)`
|