Files
godot-docs-l10n/classes/zh_Hans/class_collisionshape2d.rst
Rémi Verschelde c3f2364c10 Sync classref with 4.6 branch
Lots of translations invalidated (fuzzied) as we just synced Weblate.
2025-12-19 16:39:51 +01:00

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
描述
----
A node that provides a :ref:`Shape2D<class_Shape2D>` to a :ref:`CollisionObject2D<class_CollisionObject2D>` parent and allows it to be edited. This can give a detection shape to an :ref:`Area2D<class_Area2D>` or turn a :ref:`PhysicsBody2D<class_PhysicsBody2D>` into a solid object.
.. 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**\ (\ )
碰撞形状的颜色,在编辑器中显示,勾选编辑器顶部的 **调试 > 显示碰撞形状** 时也会在运行项目时显示。
\ **注意:**\ 默认值为 :ref:`ProjectSettings.debug/shapes/collision/shape_color<class_ProjectSettings_property_debug/shapes/collision/shape_color>`\ 。这里记录的 ``Color(0, 0, 0, 0)`` 值是占位符,不是实际的默认调试颜色。
.. 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 (无返回值。)`