CollisionObject2D.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="CollisionObject2D" inherits="Node2D" category="Core" version="3.1.2">
  3. <brief_description>
  4. Base node for 2D collision objects.
  5. </brief_description>
  6. <description>
  7. CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision [Shape2D]s. Each shape must be assigned to a [i]shape owner[/i]. The CollisionObject2D can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the [code]shape_owner_*[/code] methods.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="_input_event" qualifiers="virtual">
  13. <return type="void">
  14. </return>
  15. <argument index="0" name="viewport" type="Object">
  16. </argument>
  17. <argument index="1" name="event" type="InputEvent">
  18. </argument>
  19. <argument index="2" name="shape_idx" type="int">
  20. </argument>
  21. <description>
  22. Accepts unhandled [InputEvent]s. Requires [member input_pickable] to be [code]true[/code]. [code]shape_idx[/code] is the child index of the clicked [Shape2D]. Connect to the [code]input_event[/code] signal to easily pick up these events.
  23. </description>
  24. </method>
  25. <method name="create_shape_owner">
  26. <return type="int">
  27. </return>
  28. <argument index="0" name="owner" type="Object">
  29. </argument>
  30. <description>
  31. Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
  32. </description>
  33. </method>
  34. <method name="get_rid" qualifiers="const">
  35. <return type="RID">
  36. </return>
  37. <description>
  38. Returns the object's [RID].
  39. </description>
  40. </method>
  41. <method name="get_shape_owner_one_way_collision_margin" qualifiers="const">
  42. <return type="float">
  43. </return>
  44. <argument index="0" name="owner_id" type="int">
  45. </argument>
  46. <description>
  47. </description>
  48. </method>
  49. <method name="get_shape_owners">
  50. <return type="Array">
  51. </return>
  52. <description>
  53. Returns an [Array] of [code]owner_id[/code] identifiers. You can use these ids in other methods that take [code]owner_id[/code] as an argument.
  54. </description>
  55. </method>
  56. <method name="is_shape_owner_disabled" qualifiers="const">
  57. <return type="bool">
  58. </return>
  59. <argument index="0" name="owner_id" type="int">
  60. </argument>
  61. <description>
  62. If [code]true[/code], the shape owner and its shapes are disabled.
  63. </description>
  64. </method>
  65. <method name="is_shape_owner_one_way_collision_enabled" qualifiers="const">
  66. <return type="bool">
  67. </return>
  68. <argument index="0" name="owner_id" type="int">
  69. </argument>
  70. <description>
  71. Returns [code]true[/code] if collisions for the shape owner originating from this [code]CollisionObject2D[/code] will not be reported to collided with [code]CollisionObject2D[/code]s.
  72. </description>
  73. </method>
  74. <method name="remove_shape_owner">
  75. <return type="void">
  76. </return>
  77. <argument index="0" name="owner_id" type="int">
  78. </argument>
  79. <description>
  80. Removes the given shape owner.
  81. </description>
  82. </method>
  83. <method name="shape_find_owner" qualifiers="const">
  84. <return type="int">
  85. </return>
  86. <argument index="0" name="shape_index" type="int">
  87. </argument>
  88. <description>
  89. Returns the [code]owner_id[/code] of the given shape.
  90. </description>
  91. </method>
  92. <method name="shape_owner_add_shape">
  93. <return type="void">
  94. </return>
  95. <argument index="0" name="owner_id" type="int">
  96. </argument>
  97. <argument index="1" name="shape" type="Shape2D">
  98. </argument>
  99. <description>
  100. Adds a [Shape2D] to the shape owner.
  101. </description>
  102. </method>
  103. <method name="shape_owner_clear_shapes">
  104. <return type="void">
  105. </return>
  106. <argument index="0" name="owner_id" type="int">
  107. </argument>
  108. <description>
  109. Removes all shapes from the shape owner.
  110. </description>
  111. </method>
  112. <method name="shape_owner_get_owner" qualifiers="const">
  113. <return type="Object">
  114. </return>
  115. <argument index="0" name="owner_id" type="int">
  116. </argument>
  117. <description>
  118. Returns the parent object of the given shape owner.
  119. </description>
  120. </method>
  121. <method name="shape_owner_get_shape" qualifiers="const">
  122. <return type="Shape2D">
  123. </return>
  124. <argument index="0" name="owner_id" type="int">
  125. </argument>
  126. <argument index="1" name="shape_id" type="int">
  127. </argument>
  128. <description>
  129. Returns the [Shape2D] with the given id from the given shape owner.
  130. </description>
  131. </method>
  132. <method name="shape_owner_get_shape_count" qualifiers="const">
  133. <return type="int">
  134. </return>
  135. <argument index="0" name="owner_id" type="int">
  136. </argument>
  137. <description>
  138. Returns the number of shapes the given shape owner contains.
  139. </description>
  140. </method>
  141. <method name="shape_owner_get_shape_index" qualifiers="const">
  142. <return type="int">
  143. </return>
  144. <argument index="0" name="owner_id" type="int">
  145. </argument>
  146. <argument index="1" name="shape_id" type="int">
  147. </argument>
  148. <description>
  149. Returns the child index of the [Shape2D] with the given id from the given shape owner.
  150. </description>
  151. </method>
  152. <method name="shape_owner_get_transform" qualifiers="const">
  153. <return type="Transform2D">
  154. </return>
  155. <argument index="0" name="owner_id" type="int">
  156. </argument>
  157. <description>
  158. Returns the shape owner's [Transform2D].
  159. </description>
  160. </method>
  161. <method name="shape_owner_remove_shape">
  162. <return type="void">
  163. </return>
  164. <argument index="0" name="owner_id" type="int">
  165. </argument>
  166. <argument index="1" name="shape_id" type="int">
  167. </argument>
  168. <description>
  169. Removes a shape from the given shape owner.
  170. </description>
  171. </method>
  172. <method name="shape_owner_set_disabled">
  173. <return type="void">
  174. </return>
  175. <argument index="0" name="owner_id" type="int">
  176. </argument>
  177. <argument index="1" name="disabled" type="bool">
  178. </argument>
  179. <description>
  180. If [code]true[/code], disables the given shape owner.
  181. </description>
  182. </method>
  183. <method name="shape_owner_set_one_way_collision">
  184. <return type="void">
  185. </return>
  186. <argument index="0" name="owner_id" type="int">
  187. </argument>
  188. <argument index="1" name="enable" type="bool">
  189. </argument>
  190. <description>
  191. If [code]enable[/code] is [code]true[/code], collisions for the shape owner originating from this [code]CollisionObject2D[/code] will not be reported to collided with [code]CollisionObject2D[/code]s.
  192. </description>
  193. </method>
  194. <method name="shape_owner_set_one_way_collision_margin">
  195. <return type="void">
  196. </return>
  197. <argument index="0" name="owner_id" type="int">
  198. </argument>
  199. <argument index="1" name="margin" type="float">
  200. </argument>
  201. <description>
  202. </description>
  203. </method>
  204. <method name="shape_owner_set_transform">
  205. <return type="void">
  206. </return>
  207. <argument index="0" name="owner_id" type="int">
  208. </argument>
  209. <argument index="1" name="transform" type="Transform2D">
  210. </argument>
  211. <description>
  212. Sets the [Transform2D] of the given shape owner.
  213. </description>
  214. </method>
  215. </methods>
  216. <members>
  217. <member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable">
  218. If [code]true[/code], 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 [code]collision_layer[/code] bit to be set.
  219. </member>
  220. </members>
  221. <signals>
  222. <signal name="input_event">
  223. <argument index="0" name="viewport" type="Node">
  224. </argument>
  225. <argument index="1" name="event" type="InputEvent">
  226. </argument>
  227. <argument index="2" name="shape_idx" type="int">
  228. </argument>
  229. <description>
  230. Emitted when an input event occurs. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. See [method _input_event] for details.
  231. </description>
  232. </signal>
  233. <signal name="mouse_entered">
  234. <description>
  235. Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
  236. </description>
  237. </signal>
  238. <signal name="mouse_exited">
  239. <description>
  240. Emitted when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
  241. </description>
  242. </signal>
  243. </signals>
  244. <constants>
  245. </constants>
  246. </class>