mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-09 07:29:06 +00:00
160 lines
11 KiB
ReStructuredText
160 lines
11 KiB
ReStructuredText
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
|
|
|
|
.. _class_CollisionObject2D:
|
|
|
|
CollisionObject2D
|
|
=================
|
|
|
|
**Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
|
|
|
|
**Inherited By:** :ref:`Area2D<class_area2d>`, :ref:`PhysicsBody2D<class_physicsbody2d>`
|
|
|
|
**Category:** Core
|
|
|
|
Brief Description
|
|
-----------------
|
|
|
|
Base node for 2D collisionables.
|
|
|
|
Member Functions
|
|
----------------
|
|
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`_input_event<class_CollisionObject2D__input_event>` **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)** virtual |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`add_shape<class_CollisionObject2D_add_shape>` **(** :ref:`Shape2D<class_shape2d>` shape, :ref:`Transform2D<class_transform2d>` transform=((1, 0), (0, 1), (0, 0)) **)** |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`clear_shapes<class_CollisionObject2D_clear_shapes>` **(** **)** |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_rid>` | :ref:`get_rid<class_CollisionObject2D_get_rid>` **(** **)** const |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Shape2D<class_shape2d>` | :ref:`get_shape<class_CollisionObject2D_get_shape>` **(** :ref:`int<class_int>` shape_idx **)** const |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_shape_count<class_CollisionObject2D_get_shape_count>` **(** **)** const |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_transform2d>` | :ref:`get_shape_transform<class_CollisionObject2D_get_shape_transform>` **(** :ref:`int<class_int>` shape_idx **)** const |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_pickable<class_CollisionObject2D_is_pickable>` **(** **)** const |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_shape_set_as_trigger<class_CollisionObject2D_is_shape_set_as_trigger>` **(** :ref:`int<class_int>` shape_idx **)** const |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`remove_shape<class_CollisionObject2D_remove_shape>` **(** :ref:`int<class_int>` shape_idx **)** |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_pickable<class_CollisionObject2D_set_pickable>` **(** :ref:`bool<class_bool>` enabled **)** |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_shape<class_CollisionObject2D_set_shape>` **(** :ref:`int<class_int>` shape_idx, :ref:`Shape<class_shape>` shape **)** |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_shape_as_trigger<class_CollisionObject2D_set_shape_as_trigger>` **(** :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable **)** |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_shape_transform<class_CollisionObject2D_set_shape_transform>` **(** :ref:`int<class_int>` shape_idx, :ref:`Transform2D<class_transform2d>` transform **)** |
|
|
+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Signals
|
|
-------
|
|
|
|
- **input_event** **(** :ref:`Object<class_object>` viewport, :ref:`Object<class_object>` event, :ref:`int<class_int>` shape_idx **)**
|
|
- **mouse_entered** **(** **)**
|
|
This event fires only once when the mouse pointer enters any shape of this object.
|
|
|
|
- **mouse_exited** **(** **)**
|
|
This event fires only once when the mouse pointer exits all shapes of this object.
|
|
|
|
|
|
Member Variables
|
|
----------------
|
|
|
|
- :ref:`bool<class_bool>` **input_pickable**
|
|
|
|
Description
|
|
-----------
|
|
|
|
CollisionObject2D is the base class for 2D physics collisionables. They can hold any number of 2D collision shapes. Usually, they are edited by placing :ref:`CollisionShape2D<class_collisionshape2d>` and/or :ref:`CollisionPolygon2D<class_collisionpolygon2d>` nodes as children. Such nodes are for reference and not present outside the editor, so code should use the regular shape API.
|
|
|
|
Member Function Description
|
|
---------------------------
|
|
|
|
.. _class_CollisionObject2D__input_event:
|
|
|
|
- void **_input_event** **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)** virtual
|
|
|
|
.. _class_CollisionObject2D_add_shape:
|
|
|
|
- void **add_shape** **(** :ref:`Shape2D<class_shape2d>` shape, :ref:`Transform2D<class_transform2d>` transform=((1, 0), (0, 1), (0, 0)) **)**
|
|
|
|
Add a :ref:`Shape2D<class_shape2d>` to the collision body, with a given custom transform.
|
|
|
|
.. _class_CollisionObject2D_clear_shapes:
|
|
|
|
- void **clear_shapes** **(** **)**
|
|
|
|
Remove all shapes.
|
|
|
|
.. _class_CollisionObject2D_get_rid:
|
|
|
|
- :ref:`RID<class_rid>` **get_rid** **(** **)** const
|
|
|
|
Return the RID of this object.
|
|
|
|
.. _class_CollisionObject2D_get_shape:
|
|
|
|
- :ref:`Shape2D<class_shape2d>` **get_shape** **(** :ref:`int<class_int>` shape_idx **)** const
|
|
|
|
Return the shape in the given index.
|
|
|
|
.. _class_CollisionObject2D_get_shape_count:
|
|
|
|
- :ref:`int<class_int>` **get_shape_count** **(** **)** const
|
|
|
|
Return the amount of shapes in the collision body. Because a :ref:`CollisionPolygon2D<class_collisionpolygon2d>` can generate more than one :ref:`Shape2D<class_shape2d>`, the amount returned does not have to match the sum of :ref:`CollisionShape2D<class_collisionshape2d>` and :ref:`CollisionPolygon2D<class_collisionpolygon2d>`.
|
|
|
|
.. _class_CollisionObject2D_get_shape_transform:
|
|
|
|
- :ref:`Transform2D<class_transform2d>` **get_shape_transform** **(** :ref:`int<class_int>` shape_idx **)** const
|
|
|
|
Return the shape transform in the given index.
|
|
|
|
.. _class_CollisionObject2D_is_pickable:
|
|
|
|
- :ref:`bool<class_bool>` **is_pickable** **(** **)** const
|
|
|
|
Return whether this object is pickable.
|
|
|
|
.. _class_CollisionObject2D_is_shape_set_as_trigger:
|
|
|
|
- :ref:`bool<class_bool>` **is_shape_set_as_trigger** **(** :ref:`int<class_int>` shape_idx **)** const
|
|
|
|
Return whether a shape is a trigger. A trigger shape detects collisions, but is otherwise unaffected by physics (i.e. colliding objects will not get blocked).
|
|
|
|
.. _class_CollisionObject2D_remove_shape:
|
|
|
|
- void **remove_shape** **(** :ref:`int<class_int>` shape_idx **)**
|
|
|
|
Remove the shape in the given index.
|
|
|
|
.. _class_CollisionObject2D_set_pickable:
|
|
|
|
- void **set_pickable** **(** :ref:`bool<class_bool>` enabled **)**
|
|
|
|
Set whether this object is pickable. A pickable object can detect the mouse pointer enter/leave it and, if the mouse is inside it, report input events.
|
|
|
|
.. _class_CollisionObject2D_set_shape:
|
|
|
|
- void **set_shape** **(** :ref:`int<class_int>` shape_idx, :ref:`Shape<class_shape>` shape **)**
|
|
|
|
Change a shape in the collision body.
|
|
|
|
.. _class_CollisionObject2D_set_shape_as_trigger:
|
|
|
|
- void **set_shape_as_trigger** **(** :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable **)**
|
|
|
|
Set whether a shape is a trigger. A trigger shape detects collisions, but is otherwise unaffected by physics (i.e. colliding objects will not get blocked).
|
|
|
|
.. _class_CollisionObject2D_set_shape_transform:
|
|
|
|
- void **set_shape_transform** **(** :ref:`int<class_int>` shape_idx, :ref:`Transform2D<class_transform2d>` transform **)**
|
|
|
|
Change the shape transform in the collision body.
|
|
|
|
|