Area2D.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Area2D" inherits="CollisionObject2D" category="Core" version="3.0.alpha.custom_build">
  3. <brief_description>
  4. 2D area for detection and 2D physics influence.
  5. </brief_description>
  6. <description>
  7. 2D area that detects [CollisionObject2D] nodes overlapping, entering, or exiting. Can also alter or override local physics parameters (gravity, damping).
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <demos>
  12. </demos>
  13. <methods>
  14. <method name="get_angular_damp" qualifiers="const">
  15. <return type="float">
  16. </return>
  17. <description>
  18. Return the angular damp rate.
  19. </description>
  20. </method>
  21. <method name="get_audio_bus_name" qualifiers="const">
  22. <return type="String">
  23. </return>
  24. <description>
  25. </description>
  26. </method>
  27. <method name="get_collision_layer" qualifiers="const">
  28. <return type="int">
  29. </return>
  30. <description>
  31. Return the physics layer this area is in.
  32. </description>
  33. </method>
  34. <method name="get_collision_layer_bit" qualifiers="const">
  35. <return type="bool">
  36. </return>
  37. <argument index="0" name="bit" type="int">
  38. </argument>
  39. <description>
  40. Return an individual bit on the layer mask. Describes whether other areas will collide with this one on the given layer.
  41. </description>
  42. </method>
  43. <method name="get_collision_mask" qualifiers="const">
  44. <return type="int">
  45. </return>
  46. <description>
  47. Return the physics layers this area will scan to determine collisions.
  48. </description>
  49. </method>
  50. <method name="get_collision_mask_bit" qualifiers="const">
  51. <return type="bool">
  52. </return>
  53. <argument index="0" name="bit" type="int">
  54. </argument>
  55. <description>
  56. Return an individual bit on the collision mask. Describes whether this area will collide with others on the given layer.
  57. </description>
  58. </method>
  59. <method name="get_gravity" qualifiers="const">
  60. <return type="float">
  61. </return>
  62. <description>
  63. Return the gravity intensity.
  64. </description>
  65. </method>
  66. <method name="get_gravity_distance_scale" qualifiers="const">
  67. <return type="float">
  68. </return>
  69. <description>
  70. Return the falloff factor for point gravity.
  71. </description>
  72. </method>
  73. <method name="get_gravity_vector" qualifiers="const">
  74. <return type="Vector2">
  75. </return>
  76. <description>
  77. Return the gravity vector. If gravity is a point (see [method is_gravity_a_point]), this will be the attraction center.
  78. </description>
  79. </method>
  80. <method name="get_linear_damp" qualifiers="const">
  81. <return type="float">
  82. </return>
  83. <description>
  84. Return the linear damp rate.
  85. </description>
  86. </method>
  87. <method name="get_overlapping_areas" qualifiers="const">
  88. <return type="Array">
  89. </return>
  90. <description>
  91. Returns a list of intersecting [code]Area2D[/code]s.
  92. </description>
  93. </method>
  94. <method name="get_overlapping_bodies" qualifiers="const">
  95. <return type="Array">
  96. </return>
  97. <description>
  98. Returns a list of intersecting [PhysicsBody2D]s.
  99. </description>
  100. </method>
  101. <method name="get_priority" qualifiers="const">
  102. <return type="float">
  103. </return>
  104. <description>
  105. Return the processing order of this area.
  106. </description>
  107. </method>
  108. <method name="get_space_override_mode" qualifiers="const">
  109. <return type="int" enum="Area2D.SpaceOverride">
  110. </return>
  111. <description>
  112. Return the space override mode.
  113. </description>
  114. </method>
  115. <method name="is_gravity_a_point" qualifiers="const">
  116. <return type="bool">
  117. </return>
  118. <description>
  119. Return whether gravity is a point. A point gravity will attract objects towards it, as opposed to a gravity vector, which moves them in a given direction.
  120. </description>
  121. </method>
  122. <method name="is_monitorable" qualifiers="const">
  123. <return type="bool">
  124. </return>
  125. <description>
  126. Return whether this area can be detected by other, monitoring, areas.
  127. </description>
  128. </method>
  129. <method name="is_monitoring" qualifiers="const">
  130. <return type="bool">
  131. </return>
  132. <description>
  133. Return whether this area detects bodies/areas entering/exiting it.
  134. </description>
  135. </method>
  136. <method name="is_overriding_audio_bus" qualifiers="const">
  137. <return type="bool">
  138. </return>
  139. <description>
  140. </description>
  141. </method>
  142. <method name="overlaps_area" qualifiers="const">
  143. <return type="bool">
  144. </return>
  145. <argument index="0" name="area" type="Node">
  146. </argument>
  147. <description>
  148. If [code]true[/code] the given area overlaps the Area2D.
  149. </description>
  150. </method>
  151. <method name="overlaps_body" qualifiers="const">
  152. <return type="bool">
  153. </return>
  154. <argument index="0" name="body" type="Node">
  155. </argument>
  156. <description>
  157. If [code]true[/code] the given body overlaps the Area2D.
  158. </description>
  159. </method>
  160. <method name="set_angular_damp">
  161. <return type="void">
  162. </return>
  163. <argument index="0" name="angular_damp" type="float">
  164. </argument>
  165. <description>
  166. Set the rate at which objects stop spinning in this area, if there are not any other forces making it spin. The value is a fraction of its current speed, lost per second. Thus, a value of 1.0 should mean stopping immediately, and 0.0 means the object never stops.
  167. In practice, as the fraction of speed lost gets smaller with each frame, a value of 1.0 does not mean the object will stop in exactly one second. Only when the physics calculations are done at 1 frame per second, it does stop in a second.
  168. </description>
  169. </method>
  170. <method name="set_audio_bus_name">
  171. <return type="void">
  172. </return>
  173. <argument index="0" name="name" type="String">
  174. </argument>
  175. <description>
  176. </description>
  177. </method>
  178. <method name="set_audio_bus_override">
  179. <return type="void">
  180. </return>
  181. <argument index="0" name="enable" type="bool">
  182. </argument>
  183. <description>
  184. </description>
  185. </method>
  186. <method name="set_collision_layer">
  187. <return type="void">
  188. </return>
  189. <argument index="0" name="collision_layer" type="int">
  190. </argument>
  191. <description>
  192. Set the physics layers this area is in.
  193. Collidable objects can exist in any of 32 different layers. These layers are not visual, but more of a tagging system instead. A collidable can use these layers/tags to select with which objects it can collide, using [method set_collision_mask].
  194. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A.
  195. </description>
  196. </method>
  197. <method name="set_collision_layer_bit">
  198. <return type="void">
  199. </return>
  200. <argument index="0" name="bit" type="int">
  201. </argument>
  202. <argument index="1" name="value" type="bool">
  203. </argument>
  204. <description>
  205. Set/clear individual bits on the layer mask. This makes getting an area in/out of only one layer easier.
  206. </description>
  207. </method>
  208. <method name="set_collision_mask">
  209. <return type="void">
  210. </return>
  211. <argument index="0" name="collision_mask" type="int">
  212. </argument>
  213. <description>
  214. Set the physics layers this area can scan for collisions.
  215. </description>
  216. </method>
  217. <method name="set_collision_mask_bit">
  218. <return type="void">
  219. </return>
  220. <argument index="0" name="bit" type="int">
  221. </argument>
  222. <argument index="1" name="value" type="bool">
  223. </argument>
  224. <description>
  225. Set/clear individual bits on the collision mask. This makes selecting the areas scanned easier.
  226. </description>
  227. </method>
  228. <method name="set_gravity">
  229. <return type="void">
  230. </return>
  231. <argument index="0" name="gravity" type="float">
  232. </argument>
  233. <description>
  234. Set the gravity intensity. This is useful to alter the force of gravity without altering its direction.
  235. This value multiplies the gravity vector, whether it is the given vector ([method set_gravity_vector]), or a calculated one (when using a center of gravity).
  236. </description>
  237. </method>
  238. <method name="set_gravity_distance_scale">
  239. <return type="void">
  240. </return>
  241. <argument index="0" name="distance_scale" type="float">
  242. </argument>
  243. <description>
  244. Set the falloff factor for point gravity. The greater this value is, the faster the strength of gravity decreases with the square of distance.
  245. </description>
  246. </method>
  247. <method name="set_gravity_is_point">
  248. <return type="void">
  249. </return>
  250. <argument index="0" name="enable" type="bool">
  251. </argument>
  252. <description>
  253. When overriding space parameters, this method sets whether this area has a center of gravity. To set/get the location of the center of gravity, use [method set_gravity_vector]/[method get_gravity_vector].
  254. </description>
  255. </method>
  256. <method name="set_gravity_vector">
  257. <return type="void">
  258. </return>
  259. <argument index="0" name="vector" type="Vector2">
  260. </argument>
  261. <description>
  262. Set the gravity vector. This vector does not have to be normalized.
  263. If gravity is a point (see [method is_gravity_a_point]), this will be the attraction center.
  264. </description>
  265. </method>
  266. <method name="set_linear_damp">
  267. <return type="void">
  268. </return>
  269. <argument index="0" name="linear_damp" type="float">
  270. </argument>
  271. <description>
  272. Set the rate at which objects stop moving in this area, if there are not any other forces moving it. The value is a fraction of its current speed, lost per second. Thus, a value of 1.0 should mean stopping immediately, and 0.0 means the object never stops.
  273. In practice, as the fraction of speed lost gets smaller with each frame, a value of 1.0 does not mean the object will stop in exactly one second. Only when the physics calculations are done at 1 frame per second, it does stop in a second.
  274. </description>
  275. </method>
  276. <method name="set_monitorable">
  277. <return type="void">
  278. </return>
  279. <argument index="0" name="enable" type="bool">
  280. </argument>
  281. <description>
  282. Set whether this area can be detected by other, monitoring, areas. Only areas need to be marked as monitorable. Bodies are always so.
  283. </description>
  284. </method>
  285. <method name="set_monitoring">
  286. <return type="void">
  287. </return>
  288. <argument index="0" name="enable" type="bool">
  289. </argument>
  290. <description>
  291. Set whether this area can detect bodies/areas entering/exiting it.
  292. </description>
  293. </method>
  294. <method name="set_priority">
  295. <return type="void">
  296. </return>
  297. <argument index="0" name="priority" type="float">
  298. </argument>
  299. <description>
  300. Set the order in which the area is processed. Greater values mean the area gets processed first. This is useful for areas which have a space override different from AREA_SPACE_OVERRIDE_DISABLED or AREA_SPACE_OVERRIDE_COMBINE, as they replace values, and are thus order-dependent.
  301. Areas with the same priority value get evaluated in an unpredictable order, and should be differentiated if evaluation order is to be important.
  302. </description>
  303. </method>
  304. <method name="set_space_override_mode">
  305. <return type="void">
  306. </return>
  307. <argument index="0" name="space_override_mode" type="int" enum="Area2D.SpaceOverride">
  308. </argument>
  309. <description>
  310. Set the space override mode. This mode controls how an area affects gravity and damp.
  311. AREA_SPACE_OVERRIDE_DISABLED: This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
  312. AREA_SPACE_OVERRIDE_COMBINE: This area adds its gravity/damp values to whatever has been calculated so far. This way, many overlapping areas can combine their physics to make interesting effects.
  313. AREA_SPACE_OVERRIDE_COMBINE_REPLACE: This area adds its gravity/damp values to whatever has been calculated so far. Then stops taking into account the rest of the areas, even the default one.
  314. AREA_SPACE_OVERRIDE_REPLACE: This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
  315. AREA_SPACE_OVERRIDE_REPLACE_COMBINE: This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
  316. </description>
  317. </method>
  318. </methods>
  319. <members>
  320. <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp">
  321. The rate at which objects stop spinning in this area. Represents the angular velocity lost per second. Values range from [code]0[/code] (no damping) to [code]1[/code] (full damping).
  322. </member>
  323. <member name="audio_bus_name" type="String" setter="set_audio_bus_name" getter="get_audio_bus_name">
  324. The name of the area's audio bus.
  325. </member>
  326. <member name="audio_bus_override" type="bool" setter="set_audio_bus_override" getter="is_overriding_audio_bus">
  327. If [code]true[/code] the area's audio bus overrides the default audio bus. Default value: [code]false[/code].
  328. </member>
  329. <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer">
  330. The area's physics layer(s). Collidable objects can exist in any of 32 different layers. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See also [code]collision_mask[/code].
  331. </member>
  332. <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask">
  333. The physics layers this area scans to determine collision detection.
  334. </member>
  335. <member name="gravity" type="float" setter="set_gravity" getter="get_gravity">
  336. The area's gravity intensity (ranges from -1024 to 1024). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
  337. </member>
  338. <member name="gravity_distance_scale" type="float" setter="set_gravity_distance_scale" getter="get_gravity_distance_scale">
  339. The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.
  340. </member>
  341. <member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point">
  342. If [code]true[/code] gravity is calculated from a point (set via [code]gravity_vec[/code]). Also see [code]space_override[/code]. Default value: [code]false[/code].
  343. </member>
  344. <member name="gravity_vec" type="Vector2" setter="set_gravity_vector" getter="get_gravity_vector">
  345. The area's gravity vector (not normalized). If gravity is a point (see [method is_gravity_a_point]), this will be the point of attraction.
  346. </member>
  347. <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp">
  348. The rate at which objects stop moving in this area. Represents the linear velocity lost per second. Values range from [code]0[/code] (no damping) to [code]1[/code] (full damping).
  349. </member>
  350. <member name="monitorable" type="bool" setter="set_monitorable" getter="is_monitorable">
  351. If [code]true[/code] other monitoring areas can detect this area. Default value: [code]true[/code].
  352. </member>
  353. <member name="monitoring" type="bool" setter="set_monitoring" getter="is_monitoring">
  354. If [code]true[/code] the area detects bodies or areas entering and exiting it. Default value: [code]true[/code].
  355. </member>
  356. <member name="priority" type="float" setter="set_priority" getter="get_priority">
  357. The area's priority. Higher priority areas are processed first. Default value: 0.
  358. </member>
  359. <member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" enum="Area2D.SpaceOverride">
  360. Override mode for gravity and damping calculations within this area. See the SPACE_OVERRIDE_* constants for values.
  361. </member>
  362. </members>
  363. <signals>
  364. <signal name="area_entered">
  365. <argument index="0" name="area" type="Object">
  366. </argument>
  367. <description>
  368. Emitted when another area enters.
  369. </description>
  370. </signal>
  371. <signal name="area_exited">
  372. <argument index="0" name="area" type="Object">
  373. </argument>
  374. <description>
  375. Emitted when another area exits.
  376. </description>
  377. </signal>
  378. <signal name="area_shape_entered">
  379. <argument index="0" name="area_id" type="int">
  380. </argument>
  381. <argument index="1" name="area" type="Object">
  382. </argument>
  383. <argument index="2" name="area_shape" type="int">
  384. </argument>
  385. <argument index="3" name="self_shape" type="int">
  386. </argument>
  387. <description>
  388. Emitted when another area enters, reporting which shapes overlapped.
  389. </description>
  390. </signal>
  391. <signal name="area_shape_exited">
  392. <argument index="0" name="area_id" type="int">
  393. </argument>
  394. <argument index="1" name="area" type="Object">
  395. </argument>
  396. <argument index="2" name="area_shape" type="int">
  397. </argument>
  398. <argument index="3" name="self_shape" type="int">
  399. </argument>
  400. <description>
  401. Emitted when another area exits, reporting which shapes were overlapping.
  402. </description>
  403. </signal>
  404. <signal name="body_entered">
  405. <argument index="0" name="body" type="Object">
  406. </argument>
  407. <description>
  408. Emitted when a [PhysicsBody2D] object enters.
  409. </description>
  410. </signal>
  411. <signal name="body_exited">
  412. <argument index="0" name="body" type="Object">
  413. </argument>
  414. <description>
  415. Emitted when a [PhysicsBody2D] object exits.
  416. </description>
  417. </signal>
  418. <signal name="body_shape_entered">
  419. <argument index="0" name="body_id" type="int">
  420. </argument>
  421. <argument index="1" name="body" type="Object">
  422. </argument>
  423. <argument index="2" name="body_shape" type="int">
  424. </argument>
  425. <argument index="3" name="area_shape" type="int">
  426. </argument>
  427. <description>
  428. Emitted when a [PhysicsBody2D] object enters, reporting which shapes overlapped.
  429. </description>
  430. </signal>
  431. <signal name="body_shape_exited">
  432. <argument index="0" name="body_id" type="int">
  433. </argument>
  434. <argument index="1" name="body" type="Object">
  435. </argument>
  436. <argument index="2" name="body_shape" type="int">
  437. </argument>
  438. <argument index="3" name="area_shape" type="int">
  439. </argument>
  440. <description>
  441. Emitted when a [PhysicsBody2D] object exits, reporting which shapes were overlapping.
  442. </description>
  443. </signal>
  444. </signals>
  445. <constants>
  446. <constant name="SPACE_OVERRIDE_DISABLED" value="0">
  447. This area does not affect gravity/damping.
  448. </constant>
  449. <constant name="SPACE_OVERRIDE_COMBINE" value="1">
  450. This area adds its gravity/damping values to whatever has been calculated so far (in [code]priority[/code] order).
  451. </constant>
  452. <constant name="SPACE_OVERRIDE_COMBINE_REPLACE" value="2">
  453. This area adds its gravity/damping values to whatever has been calculated so far (in [code]priority[/code] order), ignoring any lower priority areas.
  454. </constant>
  455. <constant name="SPACE_OVERRIDE_REPLACE" value="3">
  456. This area replaces any gravity/damping, even the defaults, ignoring any lower priority areas.
  457. </constant>
  458. <constant name="SPACE_OVERRIDE_REPLACE_COMBINE" value="4">
  459. This area replaces any gravity/damping calculated so far (in [code]priority[/code] order), but keeps calculating the rest of the areas.
  460. </constant>
  461. </constants>
  462. </class>