CollisionObject2D.xml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="CollisionObject2D" inherits="Node2D" version="3.3">
  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. Returns the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code].
  48. </description>
  49. </method>
  50. <method name="get_shape_owners">
  51. <return type="Array">
  52. </return>
  53. <description>
  54. 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.
  55. </description>
  56. </method>
  57. <method name="is_shape_owner_disabled" qualifiers="const">
  58. <return type="bool">
  59. </return>
  60. <argument index="0" name="owner_id" type="int">
  61. </argument>
  62. <description>
  63. If [code]true[/code], the shape owner and its shapes are disabled.
  64. </description>
  65. </method>
  66. <method name="is_shape_owner_one_way_collision_enabled" qualifiers="const">
  67. <return type="bool">
  68. </return>
  69. <argument index="0" name="owner_id" type="int">
  70. </argument>
  71. <description>
  72. Returns [code]true[/code] if collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
  73. </description>
  74. </method>
  75. <method name="remove_shape_owner">
  76. <return type="void">
  77. </return>
  78. <argument index="0" name="owner_id" type="int">
  79. </argument>
  80. <description>
  81. Removes the given shape owner.
  82. </description>
  83. </method>
  84. <method name="shape_find_owner" qualifiers="const">
  85. <return type="int">
  86. </return>
  87. <argument index="0" name="shape_index" type="int">
  88. </argument>
  89. <description>
  90. Returns the [code]owner_id[/code] of the given shape.
  91. </description>
  92. </method>
  93. <method name="shape_owner_add_shape">
  94. <return type="void">
  95. </return>
  96. <argument index="0" name="owner_id" type="int">
  97. </argument>
  98. <argument index="1" name="shape" type="Shape2D">
  99. </argument>
  100. <description>
  101. Adds a [Shape2D] to the shape owner.
  102. </description>
  103. </method>
  104. <method name="shape_owner_clear_shapes">
  105. <return type="void">
  106. </return>
  107. <argument index="0" name="owner_id" type="int">
  108. </argument>
  109. <description>
  110. Removes all shapes from the shape owner.
  111. </description>
  112. </method>
  113. <method name="shape_owner_get_owner" qualifiers="const">
  114. <return type="Object">
  115. </return>
  116. <argument index="0" name="owner_id" type="int">
  117. </argument>
  118. <description>
  119. Returns the parent object of the given shape owner.
  120. </description>
  121. </method>
  122. <method name="shape_owner_get_shape" qualifiers="const">
  123. <return type="Shape2D">
  124. </return>
  125. <argument index="0" name="owner_id" type="int">
  126. </argument>
  127. <argument index="1" name="shape_id" type="int">
  128. </argument>
  129. <description>
  130. Returns the [Shape2D] with the given id from the given shape owner.
  131. </description>
  132. </method>
  133. <method name="shape_owner_get_shape_count" qualifiers="const">
  134. <return type="int">
  135. </return>
  136. <argument index="0" name="owner_id" type="int">
  137. </argument>
  138. <description>
  139. Returns the number of shapes the given shape owner contains.
  140. </description>
  141. </method>
  142. <method name="shape_owner_get_shape_index" qualifiers="const">
  143. <return type="int">
  144. </return>
  145. <argument index="0" name="owner_id" type="int">
  146. </argument>
  147. <argument index="1" name="shape_id" type="int">
  148. </argument>
  149. <description>
  150. Returns the child index of the [Shape2D] with the given id from the given shape owner.
  151. </description>
  152. </method>
  153. <method name="shape_owner_get_transform" qualifiers="const">
  154. <return type="Transform2D">
  155. </return>
  156. <argument index="0" name="owner_id" type="int">
  157. </argument>
  158. <description>
  159. Returns the shape owner's [Transform2D].
  160. </description>
  161. </method>
  162. <method name="shape_owner_remove_shape">
  163. <return type="void">
  164. </return>
  165. <argument index="0" name="owner_id" type="int">
  166. </argument>
  167. <argument index="1" name="shape_id" type="int">
  168. </argument>
  169. <description>
  170. Removes a shape from the given shape owner.
  171. </description>
  172. </method>
  173. <method name="shape_owner_set_disabled">
  174. <return type="void">
  175. </return>
  176. <argument index="0" name="owner_id" type="int">
  177. </argument>
  178. <argument index="1" name="disabled" type="bool">
  179. </argument>
  180. <description>
  181. If [code]true[/code], disables the given shape owner.
  182. </description>
  183. </method>
  184. <method name="shape_owner_set_one_way_collision">
  185. <return type="void">
  186. </return>
  187. <argument index="0" name="owner_id" type="int">
  188. </argument>
  189. <argument index="1" name="enable" type="bool">
  190. </argument>
  191. <description>
  192. If [code]enable[/code] is [code]true[/code], collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
  193. </description>
  194. </method>
  195. <method name="shape_owner_set_one_way_collision_margin">
  196. <return type="void">
  197. </return>
  198. <argument index="0" name="owner_id" type="int">
  199. </argument>
  200. <argument index="1" name="margin" type="float">
  201. </argument>
  202. <description>
  203. Sets the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code] to [code]margin[/code] pixels.
  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" default="true">
  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. Requires at least one [code]collision_layer[/code] bit to be set.
  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. 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.
  233. </description>
  234. </signal>
  235. <signal name="mouse_entered">
  236. <description>
  237. 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.
  238. </description>
  239. </signal>
  240. <signal name="mouse_exited">
  241. <description>
  242. 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.
  243. </description>
  244. </signal>
  245. </signals>
  246. <constants>
  247. </constants>
  248. </class>