class_collisionobject2d.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_CollisionObject2D:
  4. CollisionObject2D
  5. =================
  6. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`Area2D<class_area2d>`, :ref:`PhysicsBody2D<class_physicsbody2d>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Base node for 2D collisionables.
  12. Member Functions
  13. ----------------
  14. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | 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 |
  16. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_shape<class_CollisionObject2D_add_shape>` **(** :ref:`Shape2D<class_shape2d>` shape, :ref:`Matrix32<class_matrix32>` transform=((1, 0), (0, 1), (0, 0)) **)** |
  18. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`clear_shapes<class_CollisionObject2D_clear_shapes>` **(** **)** |
  20. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`RID<class_rid>` | :ref:`get_rid<class_CollisionObject2D_get_rid>` **(** **)** const |
  22. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Shape2D<class_shape2d>` | :ref:`get_shape<class_CollisionObject2D_get_shape>` **(** :ref:`int<class_int>` shape_idx **)** const |
  24. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`get_shape_count<class_CollisionObject2D_get_shape_count>` **(** **)** const |
  26. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Matrix32<class_matrix32>` | :ref:`get_shape_transform<class_CollisionObject2D_get_shape_transform>` **(** :ref:`int<class_int>` shape_idx **)** const |
  28. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`is_pickable<class_CollisionObject2D_is_pickable>` **(** **)** const |
  30. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_shape_set_as_trigger<class_CollisionObject2D_is_shape_set_as_trigger>` **(** :ref:`int<class_int>` shape_idx **)** const |
  32. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`remove_shape<class_CollisionObject2D_remove_shape>` **(** :ref:`int<class_int>` shape_idx **)** |
  34. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set_pickable<class_CollisionObject2D_set_pickable>` **(** :ref:`bool<class_bool>` enabled **)** |
  36. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`set_shape<class_CollisionObject2D_set_shape>` **(** :ref:`int<class_int>` shape_idx, :ref:`Shape<class_shape>` shape **)** |
  38. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_shape_as_trigger<class_CollisionObject2D_set_shape_as_trigger>` **(** :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable **)** |
  40. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_shape_transform<class_CollisionObject2D_set_shape_transform>` **(** :ref:`int<class_int>` shape_idx, :ref:`Matrix32<class_matrix32>` transform **)** |
  42. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. Signals
  44. -------
  45. - **input_event** **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)**
  46. This signal triggers when an input event fires over a shape. 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.
  47. - **mouse_enter** **(** **)**
  48. This event fires only once when the mouse pointer enters any shape of this object.
  49. - **mouse_exit** **(** **)**
  50. This event fires only once when the mouse pointer exits all shapes of this object.
  51. Description
  52. -----------
  53. 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.
  54. Member Function Description
  55. ---------------------------
  56. .. _class_CollisionObject2D__input_event:
  57. - void **_input_event** **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)** virtual
  58. 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.
  59. .. _class_CollisionObject2D_add_shape:
  60. - void **add_shape** **(** :ref:`Shape2D<class_shape2d>` shape, :ref:`Matrix32<class_matrix32>` transform=((1, 0), (0, 1), (0, 0)) **)**
  61. Add a :ref:`Shape2D<class_shape2d>` to the collision body, with a given custom transform.
  62. .. _class_CollisionObject2D_clear_shapes:
  63. - void **clear_shapes** **(** **)**
  64. Remove all shapes.
  65. .. _class_CollisionObject2D_get_rid:
  66. - :ref:`RID<class_rid>` **get_rid** **(** **)** const
  67. Return the RID of this object.
  68. .. _class_CollisionObject2D_get_shape:
  69. - :ref:`Shape2D<class_shape2d>` **get_shape** **(** :ref:`int<class_int>` shape_idx **)** const
  70. Return the shape in the given index.
  71. .. _class_CollisionObject2D_get_shape_count:
  72. - :ref:`int<class_int>` **get_shape_count** **(** **)** const
  73. 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>`.
  74. .. _class_CollisionObject2D_get_shape_transform:
  75. - :ref:`Matrix32<class_matrix32>` **get_shape_transform** **(** :ref:`int<class_int>` shape_idx **)** const
  76. Return the shape transform in the given index.
  77. .. _class_CollisionObject2D_is_pickable:
  78. - :ref:`bool<class_bool>` **is_pickable** **(** **)** const
  79. Return whether this object is pickable.
  80. .. _class_CollisionObject2D_is_shape_set_as_trigger:
  81. - :ref:`bool<class_bool>` **is_shape_set_as_trigger** **(** :ref:`int<class_int>` shape_idx **)** const
  82. 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).
  83. .. _class_CollisionObject2D_remove_shape:
  84. - void **remove_shape** **(** :ref:`int<class_int>` shape_idx **)**
  85. Remove the shape in the given index.
  86. .. _class_CollisionObject2D_set_pickable:
  87. - void **set_pickable** **(** :ref:`bool<class_bool>` enabled **)**
  88. 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.
  89. .. _class_CollisionObject2D_set_shape:
  90. - void **set_shape** **(** :ref:`int<class_int>` shape_idx, :ref:`Shape<class_shape>` shape **)**
  91. Change a shape in the collision body.
  92. .. _class_CollisionObject2D_set_shape_as_trigger:
  93. - void **set_shape_as_trigger** **(** :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable **)**
  94. 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).
  95. .. _class_CollisionObject2D_set_shape_transform:
  96. - void **set_shape_transform** **(** :ref:`int<class_int>` shape_idx, :ref:`Matrix32<class_matrix32>` transform **)**
  97. Change the shape transform in the collision body.