class_collisionobject2d.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. | :ref:`int<class_int>` | :ref:`get_shape_count<class_CollisionObject2D_get_shape_count>` **(** **)** const |
  20. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`set_shape<class_CollisionObject2D_set_shape>` **(** :ref:`int<class_int>` shape_idx, :ref:`Shape<class_shape>` shape **)** |
  22. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`set_shape_transform<class_CollisionObject2D_set_shape_transform>` **(** :ref:`int<class_int>` shape_idx, :ref:`Matrix32<class_matrix32>` transform **)** |
  24. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`set_shape_as_trigger<class_CollisionObject2D_set_shape_as_trigger>` **(** :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable **)** |
  26. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Shape2D<class_shape2d>` | :ref:`get_shape<class_CollisionObject2D_get_shape>` **(** :ref:`int<class_int>` shape_idx **)** const |
  28. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Matrix32<class_matrix32>` | :ref:`get_shape_transform<class_CollisionObject2D_get_shape_transform>` **(** :ref:`int<class_int>` shape_idx **)** 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:`clear_shapes<class_CollisionObject2D_clear_shapes>` **(** **)** |
  36. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`RID<class_rid>` | :ref:`get_rid<class_CollisionObject2D_get_rid>` **(** **)** const |
  38. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_pickable<class_CollisionObject2D_set_pickable>` **(** :ref:`bool<class_bool>` enabled **)** |
  40. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`is_pickable<class_CollisionObject2D_is_pickable>` **(** **)** const |
  42. +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. Signals
  44. -------
  45. - **mouse_enter** **(** **)**
  46. - **input_event** **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)**
  47. - **mouse_exit** **(** **)**
  48. Description
  49. -----------
  50. 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.
  51. Member Function Description
  52. ---------------------------
  53. .. _class_CollisionObject2D__input_event:
  54. - void **_input_event** **(** :ref:`Object<class_object>` viewport, :ref:`InputEvent<class_inputevent>` event, :ref:`int<class_int>` shape_idx **)** virtual
  55. 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.
  56. .. _class_CollisionObject2D_add_shape:
  57. - void **add_shape** **(** :ref:`Shape2D<class_shape2d>` shape, :ref:`Matrix32<class_matrix32>` transform=1,0, 0,1, 0,0 **)**
  58. Add a :ref:`Shape2D<class_shape2d>` to the collision body, with a given custom transform.
  59. .. _class_CollisionObject2D_get_shape_count:
  60. - :ref:`int<class_int>` **get_shape_count** **(** **)** const
  61. 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>`.
  62. .. _class_CollisionObject2D_set_shape:
  63. - void **set_shape** **(** :ref:`int<class_int>` shape_idx, :ref:`Shape<class_shape>` shape **)**
  64. Change a shape in the collision body.
  65. .. _class_CollisionObject2D_set_shape_transform:
  66. - void **set_shape_transform** **(** :ref:`int<class_int>` shape_idx, :ref:`Matrix32<class_matrix32>` transform **)**
  67. Change the shape transform in the collision body.
  68. .. _class_CollisionObject2D_set_shape_as_trigger:
  69. - void **set_shape_as_trigger** **(** :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable **)**
  70. 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).
  71. .. _class_CollisionObject2D_get_shape:
  72. - :ref:`Shape2D<class_shape2d>` **get_shape** **(** :ref:`int<class_int>` shape_idx **)** const
  73. Return the shape in the given index.
  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_shape_set_as_trigger:
  78. - :ref:`bool<class_bool>` **is_shape_set_as_trigger** **(** :ref:`int<class_int>` shape_idx **)** const
  79. 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).
  80. .. _class_CollisionObject2D_remove_shape:
  81. - void **remove_shape** **(** :ref:`int<class_int>` shape_idx **)**
  82. Remove the shape in the given index.
  83. .. _class_CollisionObject2D_clear_shapes:
  84. - void **clear_shapes** **(** **)**
  85. Remove all shapes.
  86. .. _class_CollisionObject2D_get_rid:
  87. - :ref:`RID<class_rid>` **get_rid** **(** **)** const
  88. Return the RID of this object.
  89. .. _class_CollisionObject2D_set_pickable:
  90. - void **set_pickable** **(** :ref:`bool<class_bool>` enabled **)**
  91. 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.
  92. .. _class_CollisionObject2D_is_pickable:
  93. - :ref:`bool<class_bool>` **is_pickable** **(** **)** const
  94. Return whether this object is pickable.