123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- .. _class_CollisionObject2D:
- CollisionObject2D
- =================
- **Inherits:** :ref:`Node2D<class_node2d>`
- **Category:** Core
- 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:`Matrix32<class_matrix32>` transform=1,0, 0,1, 0,0 **)** |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_shape_count<class_CollisionObject2D_get_shape_count>` **(** **)** const |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_shape<class_CollisionObject2D_set_shape>` **(** :ref:`int<class_int>` shape_idx, :ref:`Shape<class_shape>` shape **)** |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_shape_transform<class_CollisionObject2D_set_shape_transform>` **(** :ref:`int<class_int>` shape_idx, :ref:`Matrix32<class_matrix32>` transform **)** |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_shape_as_trigger<class_CollisionObject2D_set_shape_as_trigger>` **(** :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable **)** |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Shape2D<class_shape2d>` | :ref:`get_shape<class_CollisionObject2D_get_shape>` **(** :ref:`int<class_int>` shape_idx **)** const |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Matrix32<class_matrix32>` | :ref:`get_shape_transform<class_CollisionObject2D_get_shape_transform>` **(** :ref:`int<class_int>` shape_idx **)** 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:`clear_shapes<class_CollisionObject2D_clear_shapes>` **(** **)** |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`RID<class_rid>` | :ref:`get_rid<class_CollisionObject2D_get_rid>` **(** **)** const |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_pickable<class_CollisionObject2D_set_pickable>` **(** :ref:`bool<class_bool>` enabled **)** |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_pickable<class_CollisionObject2D_is_pickable>` **(** **)** const |
- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- Signals
- -------
- - **mouse_enter** **(** **)**
- - **input_event** **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)**
- - **mouse_exit** **(** **)**
- 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
- This method can be used to override normal input processing. The first parameter is the viewport where the event took place. The second holds the input event received, and the third the shape of this object where it happened.
- .. _class_CollisionObject2D_add_shape:
- - void **add_shape** **(** :ref:`Shape2D<class_shape2d>` shape, :ref:`Matrix32<class_matrix32>` transform=1,0, 0,1, 0,0 **)**
- Add a :ref:`Shape2D<class_shape2d>` to the collision body, with a given custom transform.
- .. _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_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_transform:
- - void **set_shape_transform** **(** :ref:`int<class_int>` shape_idx, :ref:`Matrix32<class_matrix32>` transform **)**
- Change the shape transform 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_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_transform:
- - :ref:`Matrix32<class_matrix32>` **get_shape_transform** **(** :ref:`int<class_int>` shape_idx **)** const
- Return the shape transform in the given index.
- .. _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_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_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_is_pickable:
- - :ref:`bool<class_bool>` **is_pickable** **(** **)** const
- Return whether this object is pickable.
|