CollisionObject2D.xml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. <argument index="0" name="viewport" type="Object" />
  15. <argument index="1" name="event" type="InputEvent" />
  16. <argument index="2" name="shape_idx" type="int" />
  17. <description>
  18. 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.
  19. </description>
  20. </method>
  21. <method name="create_shape_owner">
  22. <return type="int" />
  23. <argument index="0" name="owner" type="Object" />
  24. <description>
  25. Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
  26. </description>
  27. </method>
  28. <method name="get_rid" qualifiers="const">
  29. <return type="RID" />
  30. <description>
  31. Returns the object's [RID].
  32. </description>
  33. </method>
  34. <method name="get_shape_owner_one_way_collision_margin" qualifiers="const">
  35. <return type="float" />
  36. <argument index="0" name="owner_id" type="int" />
  37. <description>
  38. Returns the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code].
  39. </description>
  40. </method>
  41. <method name="get_shape_owners">
  42. <return type="Array" />
  43. <description>
  44. 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.
  45. </description>
  46. </method>
  47. <method name="is_shape_owner_disabled" qualifiers="const">
  48. <return type="bool" />
  49. <argument index="0" name="owner_id" type="int" />
  50. <description>
  51. If [code]true[/code], the shape owner and its shapes are disabled.
  52. </description>
  53. </method>
  54. <method name="is_shape_owner_one_way_collision_enabled" qualifiers="const">
  55. <return type="bool" />
  56. <argument index="0" name="owner_id" type="int" />
  57. <description>
  58. Returns [code]true[/code] if collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
  59. </description>
  60. </method>
  61. <method name="remove_shape_owner">
  62. <return type="void" />
  63. <argument index="0" name="owner_id" type="int" />
  64. <description>
  65. Removes the given shape owner.
  66. </description>
  67. </method>
  68. <method name="shape_find_owner" qualifiers="const">
  69. <return type="int" />
  70. <argument index="0" name="shape_index" type="int" />
  71. <description>
  72. Returns the [code]owner_id[/code] of the given shape.
  73. </description>
  74. </method>
  75. <method name="shape_owner_add_shape">
  76. <return type="void" />
  77. <argument index="0" name="owner_id" type="int" />
  78. <argument index="1" name="shape" type="Shape2D" />
  79. <description>
  80. Adds a [Shape2D] to the shape owner.
  81. </description>
  82. </method>
  83. <method name="shape_owner_clear_shapes">
  84. <return type="void" />
  85. <argument index="0" name="owner_id" type="int" />
  86. <description>
  87. Removes all shapes from the shape owner.
  88. </description>
  89. </method>
  90. <method name="shape_owner_get_owner" qualifiers="const">
  91. <return type="Object" />
  92. <argument index="0" name="owner_id" type="int" />
  93. <description>
  94. Returns the parent object of the given shape owner.
  95. </description>
  96. </method>
  97. <method name="shape_owner_get_shape" qualifiers="const">
  98. <return type="Shape2D" />
  99. <argument index="0" name="owner_id" type="int" />
  100. <argument index="1" name="shape_id" type="int" />
  101. <description>
  102. Returns the [Shape2D] with the given id from the given shape owner.
  103. </description>
  104. </method>
  105. <method name="shape_owner_get_shape_count" qualifiers="const">
  106. <return type="int" />
  107. <argument index="0" name="owner_id" type="int" />
  108. <description>
  109. Returns the number of shapes the given shape owner contains.
  110. </description>
  111. </method>
  112. <method name="shape_owner_get_shape_index" qualifiers="const">
  113. <return type="int" />
  114. <argument index="0" name="owner_id" type="int" />
  115. <argument index="1" name="shape_id" type="int" />
  116. <description>
  117. Returns the child index of the [Shape2D] with the given id from the given shape owner.
  118. </description>
  119. </method>
  120. <method name="shape_owner_get_transform" qualifiers="const">
  121. <return type="Transform2D" />
  122. <argument index="0" name="owner_id" type="int" />
  123. <description>
  124. Returns the shape owner's [Transform2D].
  125. </description>
  126. </method>
  127. <method name="shape_owner_remove_shape">
  128. <return type="void" />
  129. <argument index="0" name="owner_id" type="int" />
  130. <argument index="1" name="shape_id" type="int" />
  131. <description>
  132. Removes a shape from the given shape owner.
  133. </description>
  134. </method>
  135. <method name="shape_owner_set_disabled">
  136. <return type="void" />
  137. <argument index="0" name="owner_id" type="int" />
  138. <argument index="1" name="disabled" type="bool" />
  139. <description>
  140. If [code]true[/code], disables the given shape owner.
  141. </description>
  142. </method>
  143. <method name="shape_owner_set_one_way_collision">
  144. <return type="void" />
  145. <argument index="0" name="owner_id" type="int" />
  146. <argument index="1" name="enable" type="bool" />
  147. <description>
  148. 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.
  149. </description>
  150. </method>
  151. <method name="shape_owner_set_one_way_collision_margin">
  152. <return type="void" />
  153. <argument index="0" name="owner_id" type="int" />
  154. <argument index="1" name="margin" type="float" />
  155. <description>
  156. Sets the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code] to [code]margin[/code] pixels.
  157. </description>
  158. </method>
  159. <method name="shape_owner_set_transform">
  160. <return type="void" />
  161. <argument index="0" name="owner_id" type="int" />
  162. <argument index="1" name="transform" type="Transform2D" />
  163. <description>
  164. Sets the [Transform2D] of the given shape owner.
  165. </description>
  166. </method>
  167. </methods>
  168. <members>
  169. <member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" default="true">
  170. 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.
  171. </member>
  172. </members>
  173. <signals>
  174. <signal name="input_event">
  175. <argument index="0" name="viewport" type="Node" />
  176. <argument index="1" name="event" type="InputEvent" />
  177. <argument index="2" name="shape_idx" type="int" />
  178. <description>
  179. 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.
  180. </description>
  181. </signal>
  182. <signal name="mouse_entered">
  183. <description>
  184. 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.
  185. </description>
  186. </signal>
  187. <signal name="mouse_exited">
  188. <description>
  189. 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.
  190. </description>
  191. </signal>
  192. </signals>
  193. <constants>
  194. </constants>
  195. </class>