:github_url: hide .. _class_Joint2D: Joint2D ======= **继承:** :ref:`Node2D` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` **派生:** :ref:`DampedSpringJoint2D`, :ref:`GrooveJoint2D`, :ref:`PinJoint2D` 所有 2D 物理关节的抽象基类。 .. rst-class:: classref-introduction-group 描述 ---- 2D 物理中所有关节的抽象基类。2D 关节能够将两个物理体(\ :ref:`node_a` 和 :ref:`node_b`\ )绑定在一起并施加约束。 .. rst-class:: classref-reftable-group 属性 ---- .. table:: :widths: auto +---------------------------------+--------------------------------------------------------------------+------------------+ | :ref:`float` | :ref:`bias` | ``0.0`` | +---------------------------------+--------------------------------------------------------------------+------------------+ | :ref:`bool` | :ref:`disable_collision` | ``true`` | +---------------------------------+--------------------------------------------------------------------+------------------+ | :ref:`NodePath` | :ref:`node_a` | ``NodePath("")`` | +---------------------------------+--------------------------------------------------------------------+------------------+ | :ref:`NodePath` | :ref:`node_b` | ``NodePath("")`` | +---------------------------------+--------------------------------------------------------------------+------------------+ .. rst-class:: classref-reftable-group 方法 ---- .. table:: :widths: auto +-----------------------+------------------------------------------------------------+ | :ref:`RID` | :ref:`get_rid`\ (\ ) |const| | +-----------------------+------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 属性说明 -------- .. _class_Joint2D_property_bias: .. rst-class:: classref-property :ref:`float` **bias** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_bias**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_bias**\ (\ ) 当 :ref:`node_a` 和 :ref:`node_b` 向不同方向移动时,\ :ref:`bias` 控制关节将它们拉回到原始位置的速度。\ :ref:`bias` 越低,两个实体对该关节的拉力就越大。 当被设置为 ``0`` 时,使用来自 :ref:`ProjectSettings.physics/2d/solver/default_constraint_bias` 的默认值。 .. rst-class:: classref-item-separator ---- .. _class_Joint2D_property_disable_collision: .. rst-class:: classref-property :ref:`bool` **disable_collision** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_exclude_nodes_from_collision**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **get_exclude_nodes_from_collision**\ (\ ) 如果为 ``true``\ ,则绑定在一起的两个物体不会相互碰撞。 .. rst-class:: classref-item-separator ---- .. _class_Joint2D_property_node_a: .. rst-class:: classref-property :ref:`NodePath` **node_a** = ``NodePath("")`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_node_a**\ (\ value\: :ref:`NodePath`\ ) - :ref:`NodePath` **get_node_a**\ (\ ) 连接到关节的第一个物体(A)的路径。该节点必须继承自 :ref:`PhysicsBody2D`\ 。 .. rst-class:: classref-item-separator ---- .. _class_Joint2D_property_node_b: .. rst-class:: classref-property :ref:`NodePath` **node_b** = ``NodePath("")`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_node_b**\ (\ value\: :ref:`NodePath`\ ) - :ref:`NodePath` **get_node_b**\ (\ ) 连接到关节的第二个物体(B)的路径。该节点必须继承自 :ref:`PhysicsBody2D`\ 。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 方法说明 -------- .. _class_Joint2D_method_get_rid: .. rst-class:: classref-method :ref:`RID` **get_rid**\ (\ ) |const| :ref:`🔗` 从 :ref:`PhysicsServer2D` 返回关节的内部 :ref:`RID`\ 。 .. |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 (无返回值。)`