CollisionObject2D.xml 8.0 KB

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