class_particles2d.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Particles2D:
  4. Particles2D
  5. ===========
  6. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. 2D Particle emitter
  11. Member Functions
  12. ----------------
  13. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`set_emitting<class_Particles2D_set_emitting>` **(** :ref:`bool<class_bool>` active **)** |
  15. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`is_emitting<class_Particles2D_is_emitting>` **(** **)** const |
  17. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`set_amount<class_Particles2D_set_amount>` **(** :ref:`int<class_int>` amount **)** |
  19. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`get_amount<class_Particles2D_get_amount>` **(** **)** const |
  21. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`set_lifetime<class_Particles2D_set_lifetime>` **(** :ref:`float<class_float>` lifetime **)** |
  23. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`float<class_float>` | :ref:`get_lifetime<class_Particles2D_get_lifetime>` **(** **)** const |
  25. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`set_time_scale<class_Particles2D_set_time_scale>` **(** :ref:`float<class_float>` time_scale **)** |
  27. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`get_time_scale<class_Particles2D_get_time_scale>` **(** **)** const |
  29. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`set_pre_process_time<class_Particles2D_set_pre_process_time>` **(** :ref:`float<class_float>` time **)** |
  31. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`get_pre_process_time<class_Particles2D_get_pre_process_time>` **(** **)** const |
  33. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_emit_timeout<class_Particles2D_set_emit_timeout>` **(** :ref:`float<class_float>` value **)** |
  35. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`get_emit_timeout<class_Particles2D_get_emit_timeout>` **(** **)** const |
  37. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_param<class_Particles2D_set_param>` **(** :ref:`int<class_int>` param, :ref:`float<class_float>` value **)** |
  39. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`get_param<class_Particles2D_get_param>` **(** :ref:`int<class_int>` param **)** const |
  41. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`set_randomness<class_Particles2D_set_randomness>` **(** :ref:`int<class_int>` param, :ref:`float<class_float>` value **)** |
  43. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`get_randomness<class_Particles2D_get_randomness>` **(** :ref:`int<class_int>` param **)** const |
  45. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Texture<class_texture>` | :ref:`set_texture<class_Particles2D_set_texture>` **(** :ref:`Object<class_object>` texture **)** |
  47. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Texture<class_texture>` | :ref:`get_texture<class_Particles2D_get_texture>` **(** **)** const |
  49. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_color<class_Particles2D_set_color>` **(** :ref:`Color<class_color>` color **)** |
  51. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Color<class_color>` | :ref:`get_color<class_Particles2D_get_color>` **(** **)** const |
  53. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`ColorRamp<class_colorramp>` | :ref:`set_color_ramp<class_Particles2D_set_color_ramp>` **(** :ref:`Object<class_object>` color_ramp **)** |
  55. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`ColorRamp<class_colorramp>` | :ref:`get_color_ramp<class_Particles2D_get_color_ramp>` **(** **)** const |
  57. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_emissor_offset<class_Particles2D_set_emissor_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  59. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Vector2<class_vector2>` | :ref:`get_emissor_offset<class_Particles2D_get_emissor_offset>` **(** **)** const |
  61. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set_flip_h<class_Particles2D_set_flip_h>` **(** :ref:`bool<class_bool>` enable **)** |
  63. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`bool<class_bool>` | :ref:`is_flipped_h<class_Particles2D_is_flipped_h>` **(** **)** const |
  65. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`set_flip_v<class_Particles2D_set_flip_v>` **(** :ref:`bool<class_bool>` enable **)** |
  67. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`bool<class_bool>` | :ref:`is_flipped_v<class_Particles2D_is_flipped_v>` **(** **)** const |
  69. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_h_frames<class_Particles2D_set_h_frames>` **(** :ref:`int<class_int>` enable **)** |
  71. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`int<class_int>` | :ref:`get_h_frames<class_Particles2D_get_h_frames>` **(** **)** const |
  73. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`set_v_frames<class_Particles2D_set_v_frames>` **(** :ref:`int<class_int>` enable **)** |
  75. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`int<class_int>` | :ref:`get_v_frames<class_Particles2D_get_v_frames>` **(** **)** const |
  77. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`set_emission_half_extents<class_Particles2D_set_emission_half_extents>` **(** :ref:`Vector2<class_vector2>` extents **)** |
  79. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector2<class_vector2>` | :ref:`get_emission_half_extents<class_Particles2D_get_emission_half_extents>` **(** **)** const |
  81. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`set_color_phases<class_Particles2D_set_color_phases>` **(** :ref:`int<class_int>` phases **)** |
  83. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`int<class_int>` | :ref:`get_color_phases<class_Particles2D_get_color_phases>` **(** **)** const |
  85. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | void | :ref:`set_color_phase_color<class_Particles2D_set_color_phase_color>` **(** :ref:`int<class_int>` phase, :ref:`Color<class_color>` color **)** |
  87. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`Color<class_color>` | :ref:`get_color_phase_color<class_Particles2D_get_color_phase_color>` **(** :ref:`int<class_int>` phase **)** const |
  89. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`set_color_phase_pos<class_Particles2D_set_color_phase_pos>` **(** :ref:`int<class_int>` phase, :ref:`float<class_float>` pos **)** |
  91. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`float<class_float>` | :ref:`get_color_phase_pos<class_Particles2D_get_color_phase_pos>` **(** :ref:`int<class_int>` phase **)** const |
  93. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`pre_process<class_Particles2D_pre_process>` **(** :ref:`float<class_float>` time **)** |
  95. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | void | :ref:`reset<class_Particles2D_reset>` **(** **)** |
  97. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | void | :ref:`set_use_local_space<class_Particles2D_set_use_local_space>` **(** :ref:`bool<class_bool>` enable **)** |
  99. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`bool<class_bool>` | :ref:`is_using_local_space<class_Particles2D_is_using_local_space>` **(** **)** const |
  101. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | void | :ref:`set_initial_velocity<class_Particles2D_set_initial_velocity>` **(** :ref:`Vector2<class_vector2>` velocity **)** |
  103. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`Vector2<class_vector2>` | :ref:`get_initial_velocity<class_Particles2D_get_initial_velocity>` **(** **)** const |
  105. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | void | :ref:`set_explosiveness<class_Particles2D_set_explosiveness>` **(** :ref:`float<class_float>` amount **)** |
  107. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`float<class_float>` | :ref:`get_explosiveness<class_Particles2D_get_explosiveness>` **(** **)** const |
  109. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | void | :ref:`set_emission_points<class_Particles2D_set_emission_points>` **(** :ref:`Vector2Array<class_vector2array>` points **)** |
  111. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`Vector2Array<class_vector2array>` | :ref:`get_emission_points<class_Particles2D_get_emission_points>` **(** **)** const |
  113. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  114. Numeric Constants
  115. -----------------
  116. - **PARAM_DIRECTION** = **0** --- Direction in radians at which the particles will be launched, Notice that when the direction is set to 0 the particles will be launched to the negative
  117. - **PARAM_SPREAD** = **1**
  118. - **PARAM_LINEAR_VELOCITY** = **2** --- Velocity at which the particles will be launched.
  119. - **PARAM_SPIN_VELOCITY** = **3** --- The speed at which particles will spin around its own center.
  120. - **PARAM_ORBIT_VELOCITY** = **4** --- Velocity at which the particles will orbit around the emitter center
  121. - **PARAM_GRAVITY_DIRECTION** = **5** --- Direction in radians at which the particles will be attracted
  122. - **PARAM_GRAVITY_STRENGTH** = **6** --- Strength of the gravitation attraction for each particle
  123. - **PARAM_RADIAL_ACCEL** = **7**
  124. - **PARAM_TANGENTIAL_ACCEL** = **8**
  125. - **PARAM_DAMPING** = **9** --- Amount of damping for each particle
  126. - **PARAM_INITIAL_ANGLE** = **10** --- Initial angle in radians at which each particle will be spawned
  127. - **PARAM_INITIAL_SIZE** = **11** --- Initial size of each particle
  128. - **PARAM_FINAL_SIZE** = **12** --- Final size of each particle, the particle size will interpolate to this value during its lifetime.
  129. - **PARAM_HUE_VARIATION** = **13**
  130. - **PARAM_ANIM_SPEED_SCALE** = **14**
  131. - **PARAM_ANIM_INITIAL_POS** = **15**
  132. - **PARAM_MAX** = **16**
  133. - **MAX_COLOR_PHASES** = **4**
  134. Description
  135. -----------
  136. Particles2D is a particle system 2D :ref:`Node<class_node>` that is used to simulate several types of particle effects, such as explosions, rain, snow, fireflies, or other magical-like shinny sparkles. Particles are drawn using impostors, and given their dynamic behavior, the user must provide a visibility AABB (although helpers to create one automatically exist).
  137. Member Function Description
  138. ---------------------------
  139. .. _class_Particles2D_set_emitting:
  140. - void **set_emitting** **(** :ref:`bool<class_bool>` active **)**
  141. If this is set to true then the particle emitter will emit particles, if its false it will not.
  142. .. _class_Particles2D_is_emitting:
  143. - :ref:`bool<class_bool>` **is_emitting** **(** **)** const
  144. Returns whether this emitter is currently emitting or not
  145. .. _class_Particles2D_set_amount:
  146. - void **set_amount** **(** :ref:`int<class_int>` amount **)**
  147. Sets the amount of particles spawned at each emission
  148. .. _class_Particles2D_get_amount:
  149. - :ref:`int<class_int>` **get_amount** **(** **)** const
  150. Returns the amount of particles spawned at each emission
  151. .. _class_Particles2D_set_lifetime:
  152. - void **set_lifetime** **(** :ref:`float<class_float>` lifetime **)**
  153. Sets the amount of seconds that each particle will be visible.
  154. .. _class_Particles2D_get_lifetime:
  155. - :ref:`float<class_float>` **get_lifetime** **(** **)** const
  156. Gets the amount of seconds that each particle will be visible.
  157. .. _class_Particles2D_set_time_scale:
  158. - void **set_time_scale** **(** :ref:`float<class_float>` time_scale **)**
  159. Sets the increment or decrement for the particle lifetime. for example: if the time scale is set to 2, the particles will die and move twice as fast.
  160. .. _class_Particles2D_get_time_scale:
  161. - :ref:`float<class_float>` **get_time_scale** **(** **)** const
  162. Returns the emitter time scale
  163. .. _class_Particles2D_set_pre_process_time:
  164. - void **set_pre_process_time** **(** :ref:`float<class_float>` time **)**
  165. .. _class_Particles2D_get_pre_process_time:
  166. - :ref:`float<class_float>` **get_pre_process_time** **(** **)** const
  167. .. _class_Particles2D_set_emit_timeout:
  168. - void **set_emit_timeout** **(** :ref:`float<class_float>` value **)**
  169. Sets the amount of seconds during which the emitter will spawn particles, after the specified seconds the emitter state will be set to non emitting, so calling :ref:`is_emitting<class_Particles2D_is_emitting>` will return false. If the timeout is 0 the emitter will spawn forever.
  170. .. _class_Particles2D_get_emit_timeout:
  171. - :ref:`float<class_float>` **get_emit_timeout** **(** **)** const
  172. Returns the amount of seconds during which the emitter will spawn particles
  173. .. _class_Particles2D_set_param:
  174. - void **set_param** **(** :ref:`int<class_int>` param, :ref:`float<class_float>` value **)**
  175. Sets the value of the specified emitter parameter (see the constants secction for the list of parameters)
  176. .. _class_Particles2D_get_param:
  177. - :ref:`float<class_float>` **get_param** **(** :ref:`int<class_int>` param **)** const
  178. Returns the value of the specified emitter parameter
  179. .. _class_Particles2D_set_randomness:
  180. - void **set_randomness** **(** :ref:`int<class_int>` param, :ref:`float<class_float>` value **)**
  181. Sets the randomness value of the specified emitter parameter (see the constants secction for the list of parameters), 0 means no randomness, so every particle will have the parameters specified, 1 means that the parameter will be choosen at random, the closer the randomness value gets to 0 the more conservative the variation of the parameter will be.
  182. .. _class_Particles2D_get_randomness:
  183. - :ref:`float<class_float>` **get_randomness** **(** :ref:`int<class_int>` param **)** const
  184. Returns the randomness value of the specified emitter parameter
  185. .. _class_Particles2D_set_texture:
  186. - :ref:`Texture<class_texture>` **set_texture** **(** :ref:`Object<class_object>` texture **)**
  187. Sets the texture for each particle
  188. .. _class_Particles2D_get_texture:
  189. - :ref:`Texture<class_texture>` **get_texture** **(** **)** const
  190. Returns the texture for emitted particles
  191. .. _class_Particles2D_set_color:
  192. - void **set_color** **(** :ref:`Color<class_color>` color **)**
  193. Set the tint color for each particle.
  194. .. _class_Particles2D_get_color:
  195. - :ref:`Color<class_color>` **get_color** **(** **)** const
  196. Returns the tint color for each particle.
  197. .. _class_Particles2D_set_color_ramp:
  198. - :ref:`ColorRamp<class_colorramp>` **set_color_ramp** **(** :ref:`Object<class_object>` color_ramp **)**
  199. Sets the :ref:`ColorRamp<class_colorramp>` used to tint each particle. Particle will be tinted according to their lifetimes.
  200. .. _class_Particles2D_get_color_ramp:
  201. - :ref:`ColorRamp<class_colorramp>` **get_color_ramp** **(** **)** const
  202. Returns the :ref:`ColorRamp<class_colorramp>` used to tint each particle
  203. .. _class_Particles2D_set_emissor_offset:
  204. - void **set_emissor_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  205. Sets the particle spawn origin position relative to the emitter center. for example if this value is set to (50, 50), the particle will spawn 50 units to the right and 50 units to the bottom of the emitter center.
  206. .. _class_Particles2D_get_emissor_offset:
  207. - :ref:`Vector2<class_vector2>` **get_emissor_offset** **(** **)** const
  208. Returns the particle spawn origin position relative to the emitter.
  209. .. _class_Particles2D_set_flip_h:
  210. - void **set_flip_h** **(** :ref:`bool<class_bool>` enable **)**
  211. .. _class_Particles2D_is_flipped_h:
  212. - :ref:`bool<class_bool>` **is_flipped_h** **(** **)** const
  213. .. _class_Particles2D_set_flip_v:
  214. - void **set_flip_v** **(** :ref:`bool<class_bool>` enable **)**
  215. .. _class_Particles2D_is_flipped_v:
  216. - :ref:`bool<class_bool>` **is_flipped_v** **(** **)** const
  217. .. _class_Particles2D_set_h_frames:
  218. - void **set_h_frames** **(** :ref:`int<class_int>` enable **)**
  219. .. _class_Particles2D_get_h_frames:
  220. - :ref:`int<class_int>` **get_h_frames** **(** **)** const
  221. .. _class_Particles2D_set_v_frames:
  222. - void **set_v_frames** **(** :ref:`int<class_int>` enable **)**
  223. .. _class_Particles2D_get_v_frames:
  224. - :ref:`int<class_int>` **get_v_frames** **(** **)** const
  225. .. _class_Particles2D_set_emission_half_extents:
  226. - void **set_emission_half_extents** **(** :ref:`Vector2<class_vector2>` extents **)**
  227. Sets the half extents of the emission box, particles will be spawned at random inside this box.
  228. .. _class_Particles2D_get_emission_half_extents:
  229. - :ref:`Vector2<class_vector2>` **get_emission_half_extents** **(** **)** const
  230. Returns the half extents of the emission box.
  231. .. _class_Particles2D_set_color_phases:
  232. - void **set_color_phases** **(** :ref:`int<class_int>` phases **)**
  233. .. _class_Particles2D_get_color_phases:
  234. - :ref:`int<class_int>` **get_color_phases** **(** **)** const
  235. .. _class_Particles2D_set_color_phase_color:
  236. - void **set_color_phase_color** **(** :ref:`int<class_int>` phase, :ref:`Color<class_color>` color **)**
  237. .. _class_Particles2D_get_color_phase_color:
  238. - :ref:`Color<class_color>` **get_color_phase_color** **(** :ref:`int<class_int>` phase **)** const
  239. .. _class_Particles2D_set_color_phase_pos:
  240. - void **set_color_phase_pos** **(** :ref:`int<class_int>` phase, :ref:`float<class_float>` pos **)**
  241. .. _class_Particles2D_get_color_phase_pos:
  242. - :ref:`float<class_float>` **get_color_phase_pos** **(** :ref:`int<class_int>` phase **)** const
  243. .. _class_Particles2D_pre_process:
  244. - void **pre_process** **(** :ref:`float<class_float>` time **)**
  245. .. _class_Particles2D_reset:
  246. - void **reset** **(** **)**
  247. .. _class_Particles2D_set_use_local_space:
  248. - void **set_use_local_space** **(** :ref:`bool<class_bool>` enable **)**
  249. .. _class_Particles2D_is_using_local_space:
  250. - :ref:`bool<class_bool>` **is_using_local_space** **(** **)** const
  251. .. _class_Particles2D_set_initial_velocity:
  252. - void **set_initial_velocity** **(** :ref:`Vector2<class_vector2>` velocity **)**
  253. .. _class_Particles2D_get_initial_velocity:
  254. - :ref:`Vector2<class_vector2>` **get_initial_velocity** **(** **)** const
  255. .. _class_Particles2D_set_explosiveness:
  256. - void **set_explosiveness** **(** :ref:`float<class_float>` amount **)**
  257. .. _class_Particles2D_get_explosiveness:
  258. - :ref:`float<class_float>` **get_explosiveness** **(** **)** const
  259. .. _class_Particles2D_set_emission_points:
  260. - void **set_emission_points** **(** :ref:`Vector2Array<class_vector2array>` points **)**
  261. .. _class_Particles2D_get_emission_points:
  262. - :ref:`Vector2Array<class_vector2array>` **get_emission_points** **(** **)** const