CollisionObject2D.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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_owners">
  44. <return type="Array">
  45. </return>
  46. <description>
  47. 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.
  48. </description>
  49. </method>
  50. <method name="is_shape_owner_disabled" qualifiers="const">
  51. <return type="bool">
  52. </return>
  53. <argument index="0" name="owner_id" type="int">
  54. </argument>
  55. <description>
  56. If [code]true[/code], the shape owner and its shapes are disabled.
  57. </description>
  58. </method>
  59. <method name="is_shape_owner_one_way_collision_enabled" qualifiers="const">
  60. <return type="bool">
  61. </return>
  62. <argument index="0" name="owner_id" type="int">
  63. </argument>
  64. <description>
  65. 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.
  66. </description>
  67. </method>
  68. <method name="remove_shape_owner">
  69. <return type="void">
  70. </return>
  71. <argument index="0" name="owner_id" type="int">
  72. </argument>
  73. <description>
  74. Removes the given shape owner.
  75. </description>
  76. </method>
  77. <method name="shape_find_owner" qualifiers="const">
  78. <return type="int">
  79. </return>
  80. <argument index="0" name="shape_index" type="int">
  81. </argument>
  82. <description>
  83. Returns the [code]owner_id[/code] of the given shape.
  84. </description>
  85. </method>
  86. <method name="shape_owner_add_shape">
  87. <return type="void">
  88. </return>
  89. <argument index="0" name="owner_id" type="int">
  90. </argument>
  91. <argument index="1" name="shape" type="Shape2D">
  92. </argument>
  93. <description>
  94. Adds a [Shape2D] to the shape owner.
  95. </description>
  96. </method>
  97. <method name="shape_owner_clear_shapes">
  98. <return type="void">
  99. </return>
  100. <argument index="0" name="owner_id" type="int">
  101. </argument>
  102. <description>
  103. Removes all shapes from the shape owner.
  104. </description>
  105. </method>
  106. <method name="shape_owner_get_owner" qualifiers="const">
  107. <return type="Object">
  108. </return>
  109. <argument index="0" name="owner_id" type="int">
  110. </argument>
  111. <description>
  112. Returns the parent object of the given shape owner.
  113. </description>
  114. </method>
  115. <method name="shape_owner_get_shape" qualifiers="const">
  116. <return type="Shape2D">
  117. </return>
  118. <argument index="0" name="owner_id" type="int">
  119. </argument>
  120. <argument index="1" name="shape_id" type="int">
  121. </argument>
  122. <description>
  123. Returns the [Shape2D] with the given id from the given shape owner.
  124. </description>
  125. </method>
  126. <method name="shape_owner_get_shape_count" qualifiers="const">
  127. <return type="int">
  128. </return>
  129. <argument index="0" name="owner_id" type="int">
  130. </argument>
  131. <description>
  132. Returns the number of shapes the given shape owner contains.
  133. </description>
  134. </method>
  135. <method name="shape_owner_get_shape_index" qualifiers="const">
  136. <return type="int">
  137. </return>
  138. <argument index="0" name="owner_id" type="int">
  139. </argument>
  140. <argument index="1" name="shape_id" type="int">
  141. </argument>
  142. <description>
  143. Returns the child index of the [Shape2D] with the given id from the given shape owner.
  144. </description>
  145. </method>
  146. <method name="shape_owner_get_transform" qualifiers="const">
  147. <return type="Transform2D">
  148. </return>
  149. <argument index="0" name="owner_id" type="int">
  150. </argument>
  151. <description>
  152. Returns the shape owner's [Transform2D].
  153. </description>
  154. </method>
  155. <method name="shape_owner_remove_shape">
  156. <return type="void">
  157. </return>
  158. <argument index="0" name="owner_id" type="int">
  159. </argument>
  160. <argument index="1" name="shape_id" type="int">
  161. </argument>
  162. <description>
  163. Removes a shape from the given shape owner.
  164. </description>
  165. </method>
  166. <method name="shape_owner_set_disabled">
  167. <return type="void">
  168. </return>
  169. <argument index="0" name="owner_id" type="int">
  170. </argument>
  171. <argument index="1" name="disabled" type="bool">
  172. </argument>
  173. <description>
  174. If [code]true[/code], disables the given shape owner.
  175. </description>
  176. </method>
  177. <method name="shape_owner_set_one_way_collision">
  178. <return type="void">
  179. </return>
  180. <argument index="0" name="owner_id" type="int">
  181. </argument>
  182. <argument index="1" name="enable" type="bool">
  183. </argument>
  184. <description>
  185. 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.
  186. </description>
  187. </method>
  188. <method name="shape_owner_set_transform">
  189. <return type="void">
  190. </return>
  191. <argument index="0" name="owner_id" type="int">
  192. </argument>
  193. <argument index="1" name="transform" type="Transform2D">
  194. </argument>
  195. <description>
  196. Sets the [Transform2D] of the given shape owner.
  197. </description>
  198. </method>
  199. </methods>
  200. <members>
  201. <member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable">
  202. 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.
  203. </member>
  204. </members>
  205. <signals>
  206. <signal name="input_event">
  207. <argument index="0" name="viewport" type="Node">
  208. </argument>
  209. <argument index="1" name="event" type="InputEvent">
  210. </argument>
  211. <argument index="2" name="shape_idx" type="int">
  212. </argument>
  213. <description>
  214. Emitted when an input event occurs and [code]input_pickable[/code] is [code]true[/code]. See [method _input_event] for details.
  215. </description>
  216. </signal>
  217. <signal name="mouse_entered">
  218. <description>
  219. Emitted when the mouse pointer enters any of this object's shapes.
  220. </description>
  221. </signal>
  222. <signal name="mouse_exited">
  223. <description>
  224. Emitted when the mouse pointer exits all this object's shapes.
  225. </description>
  226. </signal>
  227. </signals>
  228. <constants>
  229. </constants>
  230. </class>