class_collisionobject2d.rst 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/CollisionObject2D.xml.
  6. .. _class_CollisionObject2D:
  7. CollisionObject2D
  8. =================
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`Area2D<class_Area2D>`, :ref:`PhysicsBody2D<class_PhysicsBody2D>`
  11. Abstract base class for 2D physics objects.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Abstract base class for 2D physics objects. **CollisionObject2D** can hold any number of :ref:`Shape2D<class_Shape2D>`\ s for collision. Each shape must be assigned to a *shape owner*. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the ``shape_owner_*`` methods.
  16. \ **Note:** Only collisions between objects within the same canvas (:ref:`Viewport<class_Viewport>` canvas or :ref:`CanvasLayer<class_CanvasLayer>`) are supported. The behavior of collisions between objects in different canvases is undefined.
  17. .. rst-class:: classref-reftable-group
  18. Properties
  19. ----------
  20. .. table::
  21. :widths: auto
  22. +--------------------------------------------------------+--------------------------------------------------------------------------------+----------+
  23. | :ref:`int<class_int>` | :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` | ``1`` |
  24. +--------------------------------------------------------+--------------------------------------------------------------------------------+----------+
  25. | :ref:`int<class_int>` | :ref:`collision_mask<class_CollisionObject2D_property_collision_mask>` | ``1`` |
  26. +--------------------------------------------------------+--------------------------------------------------------------------------------+----------+
  27. | :ref:`float<class_float>` | :ref:`collision_priority<class_CollisionObject2D_property_collision_priority>` | ``1.0`` |
  28. +--------------------------------------------------------+--------------------------------------------------------------------------------+----------+
  29. | :ref:`DisableMode<enum_CollisionObject2D_DisableMode>` | :ref:`disable_mode<class_CollisionObject2D_property_disable_mode>` | ``0`` |
  30. +--------------------------------------------------------+--------------------------------------------------------------------------------+----------+
  31. | :ref:`bool<class_bool>` | :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` | ``true`` |
  32. +--------------------------------------------------------+--------------------------------------------------------------------------------+----------+
  33. .. rst-class:: classref-reftable-group
  34. Methods
  35. -------
  36. .. table::
  37. :widths: auto
  38. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`_input_event<class_CollisionObject2D_private_method__input_event>` **(** :ref:`Viewport<class_Viewport>` viewport, :ref:`InputEvent<class_InputEvent>` event, :ref:`int<class_int>` shape_idx **)** |virtual| |
  40. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`_mouse_enter<class_CollisionObject2D_private_method__mouse_enter>` **(** **)** |virtual| |
  42. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`_mouse_exit<class_CollisionObject2D_private_method__mouse_exit>` **(** **)** |virtual| |
  44. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`_mouse_shape_enter<class_CollisionObject2D_private_method__mouse_shape_enter>` **(** :ref:`int<class_int>` shape_idx **)** |virtual| |
  46. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`_mouse_shape_exit<class_CollisionObject2D_private_method__mouse_shape_exit>` **(** :ref:`int<class_int>` shape_idx **)** |virtual| |
  48. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`create_shape_owner<class_CollisionObject2D_method_create_shape_owner>` **(** :ref:`Object<class_Object>` owner **)** |
  50. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_value<class_CollisionObject2D_method_get_collision_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  52. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_value<class_CollisionObject2D_method_get_collision_mask_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  54. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`RID<class_RID>` | :ref:`get_rid<class_CollisionObject2D_method_get_rid>` **(** **)** |const| |
  56. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`float<class_float>` | :ref:`get_shape_owner_one_way_collision_margin<class_CollisionObject2D_method_get_shape_owner_one_way_collision_margin>` **(** :ref:`int<class_int>` owner_id **)** |const| |
  58. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`get_shape_owners<class_CollisionObject2D_method_get_shape_owners>` **(** **)** |
  60. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`is_shape_owner_disabled<class_CollisionObject2D_method_is_shape_owner_disabled>` **(** :ref:`int<class_int>` owner_id **)** |const| |
  62. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`bool<class_bool>` | :ref:`is_shape_owner_one_way_collision_enabled<class_CollisionObject2D_method_is_shape_owner_one_way_collision_enabled>` **(** :ref:`int<class_int>` owner_id **)** |const| |
  64. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`remove_shape_owner<class_CollisionObject2D_method_remove_shape_owner>` **(** :ref:`int<class_int>` owner_id **)** |
  66. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_collision_layer_value<class_CollisionObject2D_method_set_collision_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  68. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`set_collision_mask_value<class_CollisionObject2D_method_set_collision_mask_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  70. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`int<class_int>` | :ref:`shape_find_owner<class_CollisionObject2D_method_shape_find_owner>` **(** :ref:`int<class_int>` shape_index **)** |const| |
  72. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`shape_owner_add_shape<class_CollisionObject2D_method_shape_owner_add_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`Shape2D<class_Shape2D>` shape **)** |
  74. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`shape_owner_clear_shapes<class_CollisionObject2D_method_shape_owner_clear_shapes>` **(** :ref:`int<class_int>` owner_id **)** |
  76. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`Object<class_Object>` | :ref:`shape_owner_get_owner<class_CollisionObject2D_method_shape_owner_get_owner>` **(** :ref:`int<class_int>` owner_id **)** |const| |
  78. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`Shape2D<class_Shape2D>` | :ref:`shape_owner_get_shape<class_CollisionObject2D_method_shape_owner_get_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** |const| |
  80. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`int<class_int>` | :ref:`shape_owner_get_shape_count<class_CollisionObject2D_method_shape_owner_get_shape_count>` **(** :ref:`int<class_int>` owner_id **)** |const| |
  82. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`int<class_int>` | :ref:`shape_owner_get_shape_index<class_CollisionObject2D_method_shape_owner_get_shape_index>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** |const| |
  84. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`Transform2D<class_Transform2D>` | :ref:`shape_owner_get_transform<class_CollisionObject2D_method_shape_owner_get_transform>` **(** :ref:`int<class_int>` owner_id **)** |const| |
  86. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`shape_owner_remove_shape<class_CollisionObject2D_method_shape_owner_remove_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** |
  88. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`shape_owner_set_disabled<class_CollisionObject2D_method_shape_owner_set_disabled>` **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` disabled **)** |
  90. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`shape_owner_set_one_way_collision<class_CollisionObject2D_method_shape_owner_set_one_way_collision>` **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` enable **)** |
  92. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`shape_owner_set_one_way_collision_margin<class_CollisionObject2D_method_shape_owner_set_one_way_collision_margin>` **(** :ref:`int<class_int>` owner_id, :ref:`float<class_float>` margin **)** |
  94. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`shape_owner_set_transform<class_CollisionObject2D_method_shape_owner_set_transform>` **(** :ref:`int<class_int>` owner_id, :ref:`Transform2D<class_Transform2D>` transform **)** |
  96. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. .. rst-class:: classref-section-separator
  98. ----
  99. .. rst-class:: classref-descriptions-group
  100. Signals
  101. -------
  102. .. _class_CollisionObject2D_signal_input_event:
  103. .. rst-class:: classref-signal
  104. **input_event** **(** :ref:`Node<class_Node>` viewport, :ref:`InputEvent<class_InputEvent>` event, :ref:`int<class_int>` shape_idx **)**
  105. Emitted when an input event occurs. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set. See :ref:`_input_event<class_CollisionObject2D_private_method__input_event>` for details.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_CollisionObject2D_signal_mouse_entered:
  109. .. rst-class:: classref-signal
  110. **mouse_entered** **(** **)**
  111. Emitted when the mouse pointer enters any of this object's shapes. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set. Note that moving between different shapes within a single **CollisionObject2D** won't cause this signal to be emitted.
  112. \ **Note:** Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the **CollisionObject2D**'s area is small. This signal may also not be emitted if another **CollisionObject2D** is overlapping the **CollisionObject2D** in question.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_CollisionObject2D_signal_mouse_exited:
  116. .. rst-class:: classref-signal
  117. **mouse_exited** **(** **)**
  118. Emitted when the mouse pointer exits all this object's shapes. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set. Note that moving between different shapes within a single **CollisionObject2D** won't cause this signal to be emitted.
  119. \ **Note:** Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the **CollisionObject2D**'s area is small. This signal may also not be emitted if another **CollisionObject2D** is overlapping the **CollisionObject2D** in question.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_CollisionObject2D_signal_mouse_shape_entered:
  123. .. rst-class:: classref-signal
  124. **mouse_shape_entered** **(** :ref:`int<class_int>` shape_idx **)**
  125. Emitted when the mouse pointer enters any of this object's shapes or moves from one shape to another. ``shape_idx`` is the child index of the newly entered :ref:`Shape2D<class_Shape2D>`. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_CollisionObject2D_signal_mouse_shape_exited:
  129. .. rst-class:: classref-signal
  130. **mouse_shape_exited** **(** :ref:`int<class_int>` shape_idx **)**
  131. Emitted when the mouse pointer exits any of this object's shapes. ``shape_idx`` is the child index of the exited :ref:`Shape2D<class_Shape2D>`. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set.
  132. .. rst-class:: classref-section-separator
  133. ----
  134. .. rst-class:: classref-descriptions-group
  135. Enumerations
  136. ------------
  137. .. _enum_CollisionObject2D_DisableMode:
  138. .. rst-class:: classref-enumeration
  139. enum **DisableMode**:
  140. .. _class_CollisionObject2D_constant_DISABLE_MODE_REMOVE:
  141. .. rst-class:: classref-enumeration-constant
  142. :ref:`DisableMode<enum_CollisionObject2D_DisableMode>` **DISABLE_MODE_REMOVE** = ``0``
  143. When :ref:`Node.process_mode<class_Node_property_process_mode>` is set to :ref:`Node.PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>`, remove from the physics simulation to stop all physics interactions with this **CollisionObject2D**.
  144. Automatically re-added to the physics simulation when the :ref:`Node<class_Node>` is processed again.
  145. .. _class_CollisionObject2D_constant_DISABLE_MODE_MAKE_STATIC:
  146. .. rst-class:: classref-enumeration-constant
  147. :ref:`DisableMode<enum_CollisionObject2D_DisableMode>` **DISABLE_MODE_MAKE_STATIC** = ``1``
  148. When :ref:`Node.process_mode<class_Node_property_process_mode>` is set to :ref:`Node.PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>`, make the body static. Doesn't affect :ref:`Area2D<class_Area2D>`. :ref:`PhysicsBody2D<class_PhysicsBody2D>` can't be affected by forces or other bodies while static.
  149. Automatically set :ref:`PhysicsBody2D<class_PhysicsBody2D>` back to its original mode when the :ref:`Node<class_Node>` is processed again.
  150. .. _class_CollisionObject2D_constant_DISABLE_MODE_KEEP_ACTIVE:
  151. .. rst-class:: classref-enumeration-constant
  152. :ref:`DisableMode<enum_CollisionObject2D_DisableMode>` **DISABLE_MODE_KEEP_ACTIVE** = ``2``
  153. When :ref:`Node.process_mode<class_Node_property_process_mode>` is set to :ref:`Node.PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>`, do not affect the physics simulation.
  154. .. rst-class:: classref-section-separator
  155. ----
  156. .. rst-class:: classref-descriptions-group
  157. Property Descriptions
  158. ---------------------
  159. .. _class_CollisionObject2D_property_collision_layer:
  160. .. rst-class:: classref-property
  161. :ref:`int<class_int>` **collision_layer** = ``1``
  162. .. rst-class:: classref-property-setget
  163. - void **set_collision_layer** **(** :ref:`int<class_int>` value **)**
  164. - :ref:`int<class_int>` **get_collision_layer** **(** **)**
  165. The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also :ref:`collision_mask<class_CollisionObject2D_property_collision_mask>`.
  166. \ **Note:** Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_CollisionObject2D_property_collision_mask:
  170. .. rst-class:: classref-property
  171. :ref:`int<class_int>` **collision_mask** = ``1``
  172. .. rst-class:: classref-property-setget
  173. - void **set_collision_mask** **(** :ref:`int<class_int>` value **)**
  174. - :ref:`int<class_int>` **get_collision_mask** **(** **)**
  175. The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>`.
  176. \ **Note:** Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  177. .. rst-class:: classref-item-separator
  178. ----
  179. .. _class_CollisionObject2D_property_collision_priority:
  180. .. rst-class:: classref-property
  181. :ref:`float<class_float>` **collision_priority** = ``1.0``
  182. .. rst-class:: classref-property-setget
  183. - void **set_collision_priority** **(** :ref:`float<class_float>` value **)**
  184. - :ref:`float<class_float>` **get_collision_priority** **(** **)**
  185. The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_CollisionObject2D_property_disable_mode:
  189. .. rst-class:: classref-property
  190. :ref:`DisableMode<enum_CollisionObject2D_DisableMode>` **disable_mode** = ``0``
  191. .. rst-class:: classref-property-setget
  192. - void **set_disable_mode** **(** :ref:`DisableMode<enum_CollisionObject2D_DisableMode>` value **)**
  193. - :ref:`DisableMode<enum_CollisionObject2D_DisableMode>` **get_disable_mode** **(** **)**
  194. Defines the behavior in physics when :ref:`Node.process_mode<class_Node_property_process_mode>` is set to :ref:`Node.PROCESS_MODE_DISABLED<class_Node_constant_PROCESS_MODE_DISABLED>`. See :ref:`DisableMode<enum_CollisionObject2D_DisableMode>` for more details about the different modes.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_CollisionObject2D_property_input_pickable:
  198. .. rst-class:: classref-property
  199. :ref:`bool<class_bool>` **input_pickable** = ``true``
  200. .. rst-class:: classref-property-setget
  201. - void **set_pickable** **(** :ref:`bool<class_bool>` value **)**
  202. - :ref:`bool<class_bool>` **is_pickable** **(** **)**
  203. If ``true``, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set.
  204. .. rst-class:: classref-section-separator
  205. ----
  206. .. rst-class:: classref-descriptions-group
  207. Method Descriptions
  208. -------------------
  209. .. _class_CollisionObject2D_private_method__input_event:
  210. .. rst-class:: classref-method
  211. void **_input_event** **(** :ref:`Viewport<class_Viewport>` viewport, :ref:`InputEvent<class_InputEvent>` event, :ref:`int<class_int>` shape_idx **)** |virtual|
  212. Accepts unhandled :ref:`InputEvent<class_InputEvent>`\ s. ``shape_idx`` is the child index of the clicked :ref:`Shape2D<class_Shape2D>`. Connect to :ref:`input_event<class_CollisionObject2D_signal_input_event>` to easily pick up these events.
  213. \ **Note:** :ref:`_input_event<class_CollisionObject2D_private_method__input_event>` requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_CollisionObject2D_private_method__mouse_enter:
  217. .. rst-class:: classref-method
  218. void **_mouse_enter** **(** **)** |virtual|
  219. Called when the mouse pointer enters any of this object's shapes. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set. Note that moving between different shapes within a single **CollisionObject2D** won't cause this function to be called.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_CollisionObject2D_private_method__mouse_exit:
  223. .. rst-class:: classref-method
  224. void **_mouse_exit** **(** **)** |virtual|
  225. Called when the mouse pointer exits all this object's shapes. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be set. Note that moving between different shapes within a single **CollisionObject2D** won't cause this function to be called.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _class_CollisionObject2D_private_method__mouse_shape_enter:
  229. .. rst-class:: classref-method
  230. void **_mouse_shape_enter** **(** :ref:`int<class_int>` shape_idx **)** |virtual|
  231. Called when the mouse pointer enters any of this object's shapes or moves from one shape to another. ``shape_idx`` is the child index of the newly entered :ref:`Shape2D<class_Shape2D>`. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be called.
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_CollisionObject2D_private_method__mouse_shape_exit:
  235. .. rst-class:: classref-method
  236. void **_mouse_shape_exit** **(** :ref:`int<class_int>` shape_idx **)** |virtual|
  237. Called when the mouse pointer exits any of this object's shapes. ``shape_idx`` is the child index of the exited :ref:`Shape2D<class_Shape2D>`. Requires :ref:`input_pickable<class_CollisionObject2D_property_input_pickable>` to be ``true`` and at least one :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` bit to be called.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_CollisionObject2D_method_create_shape_owner:
  241. .. rst-class:: classref-method
  242. :ref:`int<class_int>` **create_shape_owner** **(** :ref:`Object<class_Object>` owner **)**
  243. Creates a new shape owner for the given object. Returns ``owner_id`` of the new owner for future reference.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_CollisionObject2D_method_get_collision_layer_value:
  247. .. rst-class:: classref-method
  248. :ref:`bool<class_bool>` **get_collision_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  249. Returns whether or not the specified layer of the :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>` is enabled, given a ``layer_number`` between 1 and 32.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_CollisionObject2D_method_get_collision_mask_value:
  253. .. rst-class:: classref-method
  254. :ref:`bool<class_bool>` **get_collision_mask_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  255. Returns whether or not the specified layer of the :ref:`collision_mask<class_CollisionObject2D_property_collision_mask>` is enabled, given a ``layer_number`` between 1 and 32.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_CollisionObject2D_method_get_rid:
  259. .. rst-class:: classref-method
  260. :ref:`RID<class_RID>` **get_rid** **(** **)** |const|
  261. Returns the object's :ref:`RID<class_RID>`.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_CollisionObject2D_method_get_shape_owner_one_way_collision_margin:
  265. .. rst-class:: classref-method
  266. :ref:`float<class_float>` **get_shape_owner_one_way_collision_margin** **(** :ref:`int<class_int>` owner_id **)** |const|
  267. Returns the ``one_way_collision_margin`` of the shape owner identified by given ``owner_id``.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_CollisionObject2D_method_get_shape_owners:
  271. .. rst-class:: classref-method
  272. :ref:`PackedInt32Array<class_PackedInt32Array>` **get_shape_owners** **(** **)**
  273. Returns an :ref:`Array<class_Array>` of ``owner_id`` identifiers. You can use these ids in other methods that take ``owner_id`` as an argument.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_CollisionObject2D_method_is_shape_owner_disabled:
  277. .. rst-class:: classref-method
  278. :ref:`bool<class_bool>` **is_shape_owner_disabled** **(** :ref:`int<class_int>` owner_id **)** |const|
  279. If ``true``, the shape owner and its shapes are disabled.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_CollisionObject2D_method_is_shape_owner_one_way_collision_enabled:
  283. .. rst-class:: classref-method
  284. :ref:`bool<class_bool>` **is_shape_owner_one_way_collision_enabled** **(** :ref:`int<class_int>` owner_id **)** |const|
  285. Returns ``true`` if collisions for the shape owner originating from this **CollisionObject2D** will not be reported to collided with **CollisionObject2D**\ s.
  286. .. rst-class:: classref-item-separator
  287. ----
  288. .. _class_CollisionObject2D_method_remove_shape_owner:
  289. .. rst-class:: classref-method
  290. void **remove_shape_owner** **(** :ref:`int<class_int>` owner_id **)**
  291. Removes the given shape owner.
  292. .. rst-class:: classref-item-separator
  293. ----
  294. .. _class_CollisionObject2D_method_set_collision_layer_value:
  295. .. rst-class:: classref-method
  296. void **set_collision_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  297. Based on ``value``, enables or disables the specified layer in the :ref:`collision_layer<class_CollisionObject2D_property_collision_layer>`, given a ``layer_number`` between 1 and 32.
  298. .. rst-class:: classref-item-separator
  299. ----
  300. .. _class_CollisionObject2D_method_set_collision_mask_value:
  301. .. rst-class:: classref-method
  302. void **set_collision_mask_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  303. Based on ``value``, enables or disables the specified layer in the :ref:`collision_mask<class_CollisionObject2D_property_collision_mask>`, given a ``layer_number`` between 1 and 32.
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _class_CollisionObject2D_method_shape_find_owner:
  307. .. rst-class:: classref-method
  308. :ref:`int<class_int>` **shape_find_owner** **(** :ref:`int<class_int>` shape_index **)** |const|
  309. Returns the ``owner_id`` of the given shape.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_CollisionObject2D_method_shape_owner_add_shape:
  313. .. rst-class:: classref-method
  314. void **shape_owner_add_shape** **(** :ref:`int<class_int>` owner_id, :ref:`Shape2D<class_Shape2D>` shape **)**
  315. Adds a :ref:`Shape2D<class_Shape2D>` to the shape owner.
  316. .. rst-class:: classref-item-separator
  317. ----
  318. .. _class_CollisionObject2D_method_shape_owner_clear_shapes:
  319. .. rst-class:: classref-method
  320. void **shape_owner_clear_shapes** **(** :ref:`int<class_int>` owner_id **)**
  321. Removes all shapes from the shape owner.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_CollisionObject2D_method_shape_owner_get_owner:
  325. .. rst-class:: classref-method
  326. :ref:`Object<class_Object>` **shape_owner_get_owner** **(** :ref:`int<class_int>` owner_id **)** |const|
  327. Returns the parent object of the given shape owner.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_CollisionObject2D_method_shape_owner_get_shape:
  331. .. rst-class:: classref-method
  332. :ref:`Shape2D<class_Shape2D>` **shape_owner_get_shape** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** |const|
  333. Returns the :ref:`Shape2D<class_Shape2D>` with the given ID from the given shape owner.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_CollisionObject2D_method_shape_owner_get_shape_count:
  337. .. rst-class:: classref-method
  338. :ref:`int<class_int>` **shape_owner_get_shape_count** **(** :ref:`int<class_int>` owner_id **)** |const|
  339. Returns the number of shapes the given shape owner contains.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_CollisionObject2D_method_shape_owner_get_shape_index:
  343. .. rst-class:: classref-method
  344. :ref:`int<class_int>` **shape_owner_get_shape_index** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** |const|
  345. Returns the child index of the :ref:`Shape2D<class_Shape2D>` with the given ID from the given shape owner.
  346. .. rst-class:: classref-item-separator
  347. ----
  348. .. _class_CollisionObject2D_method_shape_owner_get_transform:
  349. .. rst-class:: classref-method
  350. :ref:`Transform2D<class_Transform2D>` **shape_owner_get_transform** **(** :ref:`int<class_int>` owner_id **)** |const|
  351. Returns the shape owner's :ref:`Transform2D<class_Transform2D>`.
  352. .. rst-class:: classref-item-separator
  353. ----
  354. .. _class_CollisionObject2D_method_shape_owner_remove_shape:
  355. .. rst-class:: classref-method
  356. void **shape_owner_remove_shape** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)**
  357. Removes a shape from the given shape owner.
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_CollisionObject2D_method_shape_owner_set_disabled:
  361. .. rst-class:: classref-method
  362. void **shape_owner_set_disabled** **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` disabled **)**
  363. If ``true``, disables the given shape owner.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_CollisionObject2D_method_shape_owner_set_one_way_collision:
  367. .. rst-class:: classref-method
  368. void **shape_owner_set_one_way_collision** **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` enable **)**
  369. If ``enable`` is ``true``, collisions for the shape owner originating from this **CollisionObject2D** will not be reported to collided with **CollisionObject2D**\ s.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_CollisionObject2D_method_shape_owner_set_one_way_collision_margin:
  373. .. rst-class:: classref-method
  374. void **shape_owner_set_one_way_collision_margin** **(** :ref:`int<class_int>` owner_id, :ref:`float<class_float>` margin **)**
  375. Sets the ``one_way_collision_margin`` of the shape owner identified by given ``owner_id`` to ``margin`` pixels.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_CollisionObject2D_method_shape_owner_set_transform:
  379. .. rst-class:: classref-method
  380. void **shape_owner_set_transform** **(** :ref:`int<class_int>` owner_id, :ref:`Transform2D<class_Transform2D>` transform **)**
  381. Sets the :ref:`Transform2D<class_Transform2D>` of the given shape owner.
  382. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  383. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  384. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  385. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  386. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  387. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  388. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`