Files
godot-docs-l10n/classes/zh_Hant/class_collisionshape2d.rst

155 lines
6.7 KiB
ReStructuredText

:github_url: hide
.. _class_CollisionShape2D:
CollisionShape2D
================
**繼承:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
:ref:`CollisionObject2D<class_CollisionObject2D>` 父級提供 :ref:`Shape2D<class_Shape2D>` 的節點。
.. rst-class:: classref-introduction-group
說明
----
:ref:`CollisionObject2D<class_CollisionObject2D>` 父級提供 :ref:`Shape2D<class_Shape2D>` 並允許對其進行編輯的節點。這可以為 :ref:`Area2D<class_Area2D>` 提供偵測形狀或將 :ref:`PhysicsBody2D<class_PhysicsBody2D>` 轉變為實體物件。
.. rst-class:: classref-introduction-group
教學
----
- :doc:`物理介紹 <../tutorials/physics/physics_introduction>`
- `2D Dodge The Creeps 範例 <https://godotengine.org/asset-library/asset/2712>`__
- `2D Pong 範例 <https://godotengine.org/asset-library/asset/2728>`__
- `2D 運動學角色演示 <https://godotengine.org/asset-library/asset/2719>`__
.. rst-class:: classref-reftable-group
屬性
----
.. table::
:widths: auto
+-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
| :ref:`Color<class_Color>` | :ref:`debug_color<class_CollisionShape2D_property_debug_color>` | ``Color(0, 0, 0, 0)`` |
+-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
| :ref:`bool<class_bool>` | :ref:`disabled<class_CollisionShape2D_property_disabled>` | ``false`` |
+-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
| :ref:`bool<class_bool>` | :ref:`one_way_collision<class_CollisionShape2D_property_one_way_collision>` | ``false`` |
+-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`one_way_collision_margin<class_CollisionShape2D_property_one_way_collision_margin>` | ``1.0`` |
+-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
| :ref:`Shape2D<class_Shape2D>` | :ref:`shape<class_CollisionShape2D_property_shape>` | |
+-------------------------------+-------------------------------------------------------------------------------------------+-----------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
屬性說明
--------
.. _class_CollisionShape2D_property_debug_color:
.. rst-class:: classref-property
:ref:`Color<class_Color>` **debug_color** = ``Color(0, 0, 0, 0)`` :ref:`🔗<class_CollisionShape2D_property_debug_color>`
.. rst-class:: classref-property-setget
- |void| **set_debug_color**\ (\ value\: :ref:`Color<class_Color>`\ )
- :ref:`Color<class_Color>` **get_debug_color**\ (\ )
The collision shape color that is displayed in the editor, or in the running project if **Debug > Visible Collision Shapes** is checked at the top of the editor.
\ **Note:** The default value is :ref:`ProjectSettings.debug/shapes/collision/shape_color<class_ProjectSettings_property_debug/shapes/collision/shape_color>`. The ``Color(0, 0, 0, 0)`` value documented here is a placeholder, and not the actual default debug color.
.. rst-class:: classref-item-separator
----
.. _class_CollisionShape2D_property_disabled:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **disabled** = ``false`` :ref:`🔗<class_CollisionShape2D_property_disabled>`
.. rst-class:: classref-property-setget
- |void| **set_disabled**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_disabled**\ (\ )
禁用的碰撞形狀在世界中沒有影響。這個屬性應該用 :ref:`Object.set_deferred()<class_Object_method_set_deferred>` 改變。
.. rst-class:: classref-item-separator
----
.. _class_CollisionShape2D_property_one_way_collision:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **one_way_collision** = ``false`` :ref:`🔗<class_CollisionShape2D_property_one_way_collision>`
.. rst-class:: classref-property-setget
- |void| **set_one_way_collision**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_one_way_collision_enabled**\ (\ )
設定此碰撞形狀是否僅應偵測到一側(頂部或底部)的碰撞。
\ **注意:**\ 如果這個 **CollisionShape2D**:ref:`Area2D<class_Area2D>` 節點的子節點,則這個屬性無效。
.. rst-class:: classref-item-separator
----
.. _class_CollisionShape2D_property_one_way_collision_margin:
.. rst-class:: classref-property
:ref:`float<class_float>` **one_way_collision_margin** = ``1.0`` :ref:`🔗<class_CollisionShape2D_property_one_way_collision_margin>`
.. rst-class:: classref-property-setget
- |void| **set_one_way_collision_margin**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_one_way_collision_margin**\ (\ )
用於單向碰撞的邊距(以圖元為單位)。較高的值將使形狀更厚,並且對於高速進入形狀的對撞機來說效果更好。
.. rst-class:: classref-item-separator
----
.. _class_CollisionShape2D_property_shape:
.. rst-class:: classref-property
:ref:`Shape2D<class_Shape2D>` **shape** :ref:`🔗<class_CollisionShape2D_property_shape>`
.. rst-class:: classref-property-setget
- |void| **set_shape**\ (\ value\: :ref:`Shape2D<class_Shape2D>`\ )
- :ref:`Shape2D<class_Shape2D>` **get_shape**\ (\ )
該碰撞形狀擁有的實際形狀。
.. |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 (無回傳值。)`