class_particles2d.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Particles2D.xml.
  6. .. _class_Particles2D:
  7. Particles2D
  8. ===========
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. GPU-based 2D particle emitter.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 2D particle node used to create a variety of particle systems and effects. **Particles2D** features an emitter that generates some number of particles at a given rate.
  15. Use the ``process_material`` property to add a :ref:`ParticlesMaterial<class_ParticlesMaterial>` to configure particle appearance and behavior. Alternatively, you can add a :ref:`ShaderMaterial<class_ShaderMaterial>` which will be applied to all particles.
  16. \ **Note:** **Particles2D** only work when using the GLES3 renderer. If using the GLES2 renderer, use :ref:`CPUParticles2D<class_CPUParticles2D>` instead. You can convert **Particles2D** to :ref:`CPUParticles2D<class_CPUParticles2D>` by selecting the node, clicking the **Particles** menu at the top of the 2D editor viewport then choosing **Convert to CPUParticles2D**.
  17. \ **Note:** On macOS, **Particles2D** rendering is much slower than :ref:`CPUParticles2D<class_CPUParticles2D>` due to transform feedback being implemented on the CPU instead of the GPU. Consider using :ref:`CPUParticles2D<class_CPUParticles2D>` instead when targeting macOS.
  18. \ **Note:** After working on a Particles node, remember to update its :ref:`visibility_rect<class_Particles2D_property_visibility_rect>` by selecting it, clicking the **Particles** menu at the top of the 2D editor viewport then choose **Generate Visibility Rect**. Otherwise, particles may suddenly disappear depending on the camera position and angle.
  19. \ **Note:** Unlike :ref:`CPUParticles2D<class_CPUParticles2D>`, **Particles2D** currently ignore the texture region defined in :ref:`AtlasTexture<class_AtlasTexture>`\ s.
  20. .. rst-class:: classref-introduction-group
  21. Tutorials
  22. ---------
  23. - :doc:`Particle systems (2D) <../tutorials/2d/particle_systems_2d>`
  24. - `2D Particles Demo <https://godotengine.org/asset-library/asset/118>`__
  25. - `2D Dodge The Creeps Demo (uses GPUParticles2D for the trail behind the player) <https://godotengine.org/asset-library/asset/515>`__
  26. .. rst-class:: classref-reftable-group
  27. Properties
  28. ----------
  29. .. table::
  30. :widths: auto
  31. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  32. | :ref:`int<class_int>` | :ref:`amount<class_Particles2D_property_amount>` | ``8`` |
  33. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  34. | :ref:`DrawOrder<enum_Particles2D_DrawOrder>` | :ref:`draw_order<class_Particles2D_property_draw_order>` | ``0`` |
  35. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`emitting<class_Particles2D_property_emitting>` | ``true`` |
  37. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  38. | :ref:`float<class_float>` | :ref:`explosiveness<class_Particles2D_property_explosiveness>` | ``0.0`` |
  39. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  40. | :ref:`int<class_int>` | :ref:`fixed_fps<class_Particles2D_property_fixed_fps>` | ``0`` |
  41. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`fract_delta<class_Particles2D_property_fract_delta>` | ``true`` |
  43. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  44. | :ref:`float<class_float>` | :ref:`lifetime<class_Particles2D_property_lifetime>` | ``1.0`` |
  45. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`local_coords<class_Particles2D_property_local_coords>` | ``true`` |
  47. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  48. | :ref:`Texture<class_Texture>` | :ref:`normal_map<class_Particles2D_property_normal_map>` | |
  49. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`one_shot<class_Particles2D_property_one_shot>` | ``false`` |
  51. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  52. | :ref:`float<class_float>` | :ref:`preprocess<class_Particles2D_property_preprocess>` | ``0.0`` |
  53. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  54. | :ref:`Material<class_Material>` | :ref:`process_material<class_Particles2D_property_process_material>` | |
  55. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  56. | :ref:`float<class_float>` | :ref:`randomness<class_Particles2D_property_randomness>` | ``0.0`` |
  57. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  58. | :ref:`float<class_float>` | :ref:`speed_scale<class_Particles2D_property_speed_scale>` | ``1.0`` |
  59. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  60. | :ref:`Texture<class_Texture>` | :ref:`texture<class_Particles2D_property_texture>` | |
  61. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  62. | :ref:`Rect2<class_Rect2>` | :ref:`visibility_rect<class_Particles2D_property_visibility_rect>` | ``Rect2( -100, -100, 200, 200 )`` |
  63. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  64. .. rst-class:: classref-reftable-group
  65. Methods
  66. -------
  67. .. table::
  68. :widths: auto
  69. +---------------------------+--------------------------------------------------------------------------------+
  70. | :ref:`Rect2<class_Rect2>` | :ref:`capture_rect<class_Particles2D_method_capture_rect>` **(** **)** |const| |
  71. +---------------------------+--------------------------------------------------------------------------------+
  72. | void | :ref:`restart<class_Particles2D_method_restart>` **(** **)** |
  73. +---------------------------+--------------------------------------------------------------------------------+
  74. .. rst-class:: classref-section-separator
  75. ----
  76. .. rst-class:: classref-descriptions-group
  77. Signals
  78. -------
  79. .. _class_Particles2D_signal_finished:
  80. .. rst-class:: classref-signal
  81. **finished** **(** **)**
  82. Emitted when all active particles have finished processing. When :ref:`one_shot<class_Particles2D_property_one_shot>` is disabled, particles will process continuously, so this is never emitted.
  83. \ **Note:** Due to the particles being computed on the GPU there might be a delay before the signal gets emitted.
  84. .. rst-class:: classref-section-separator
  85. ----
  86. .. rst-class:: classref-descriptions-group
  87. Enumerations
  88. ------------
  89. .. _enum_Particles2D_DrawOrder:
  90. .. rst-class:: classref-enumeration
  91. enum **DrawOrder**:
  92. .. _class_Particles2D_constant_DRAW_ORDER_INDEX:
  93. .. rst-class:: classref-enumeration-constant
  94. :ref:`DrawOrder<enum_Particles2D_DrawOrder>` **DRAW_ORDER_INDEX** = ``0``
  95. Particles are drawn in the order emitted.
  96. .. _class_Particles2D_constant_DRAW_ORDER_LIFETIME:
  97. .. rst-class:: classref-enumeration-constant
  98. :ref:`DrawOrder<enum_Particles2D_DrawOrder>` **DRAW_ORDER_LIFETIME** = ``1``
  99. Particles are drawn in order of remaining lifetime.
  100. .. rst-class:: classref-section-separator
  101. ----
  102. .. rst-class:: classref-descriptions-group
  103. Property Descriptions
  104. ---------------------
  105. .. _class_Particles2D_property_amount:
  106. .. rst-class:: classref-property
  107. :ref:`int<class_int>` **amount** = ``8``
  108. .. rst-class:: classref-property-setget
  109. - void **set_amount** **(** :ref:`int<class_int>` value **)**
  110. - :ref:`int<class_int>` **get_amount** **(** **)**
  111. The number of particles emitted in one emission cycle (corresponding to the :ref:`lifetime<class_Particles2D_property_lifetime>`).
  112. \ **Note:** Changing :ref:`amount<class_Particles2D_property_amount>` will reset the particle emission, therefore removing all particles that were already emitted before changing :ref:`amount<class_Particles2D_property_amount>`.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_Particles2D_property_draw_order:
  116. .. rst-class:: classref-property
  117. :ref:`DrawOrder<enum_Particles2D_DrawOrder>` **draw_order** = ``0``
  118. .. rst-class:: classref-property-setget
  119. - void **set_draw_order** **(** :ref:`DrawOrder<enum_Particles2D_DrawOrder>` value **)**
  120. - :ref:`DrawOrder<enum_Particles2D_DrawOrder>` **get_draw_order** **(** **)**
  121. Particle draw order. Uses :ref:`DrawOrder<enum_Particles2D_DrawOrder>` values.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_Particles2D_property_emitting:
  125. .. rst-class:: classref-property
  126. :ref:`bool<class_bool>` **emitting** = ``true``
  127. .. rst-class:: classref-property-setget
  128. - void **set_emitting** **(** :ref:`bool<class_bool>` value **)**
  129. - :ref:`bool<class_bool>` **is_emitting** **(** **)**
  130. If ``true``, particles are being emitted.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_Particles2D_property_explosiveness:
  134. .. rst-class:: classref-property
  135. :ref:`float<class_float>` **explosiveness** = ``0.0``
  136. .. rst-class:: classref-property-setget
  137. - void **set_explosiveness_ratio** **(** :ref:`float<class_float>` value **)**
  138. - :ref:`float<class_float>` **get_explosiveness_ratio** **(** **)**
  139. How rapidly particles in an emission cycle are emitted. If greater than ``0``, there will be a gap in emissions before the next cycle begins.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_Particles2D_property_fixed_fps:
  143. .. rst-class:: classref-property
  144. :ref:`int<class_int>` **fixed_fps** = ``0``
  145. .. rst-class:: classref-property-setget
  146. - void **set_fixed_fps** **(** :ref:`int<class_int>` value **)**
  147. - :ref:`int<class_int>` **get_fixed_fps** **(** **)**
  148. The particle system's frame rate is fixed to a value. For instance, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_Particles2D_property_fract_delta:
  152. .. rst-class:: classref-property
  153. :ref:`bool<class_bool>` **fract_delta** = ``true``
  154. .. rst-class:: classref-property-setget
  155. - void **set_fractional_delta** **(** :ref:`bool<class_bool>` value **)**
  156. - :ref:`bool<class_bool>` **get_fractional_delta** **(** **)**
  157. If ``true``, results in fractional delta calculation which has a smoother particles display effect.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_Particles2D_property_lifetime:
  161. .. rst-class:: classref-property
  162. :ref:`float<class_float>` **lifetime** = ``1.0``
  163. .. rst-class:: classref-property-setget
  164. - void **set_lifetime** **(** :ref:`float<class_float>` value **)**
  165. - :ref:`float<class_float>` **get_lifetime** **(** **)**
  166. The amount of time each particle will exist (in seconds).
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_Particles2D_property_local_coords:
  170. .. rst-class:: classref-property
  171. :ref:`bool<class_bool>` **local_coords** = ``true``
  172. .. rst-class:: classref-property-setget
  173. - void **set_use_local_coordinates** **(** :ref:`bool<class_bool>` value **)**
  174. - :ref:`bool<class_bool>` **get_use_local_coordinates** **(** **)**
  175. If ``true``, particles use the parent node's coordinate space. If ``false``, they use global coordinates.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_Particles2D_property_normal_map:
  179. .. rst-class:: classref-property
  180. :ref:`Texture<class_Texture>` **normal_map**
  181. .. rst-class:: classref-property-setget
  182. - void **set_normal_map** **(** :ref:`Texture<class_Texture>` value **)**
  183. - :ref:`Texture<class_Texture>` **get_normal_map** **(** **)**
  184. Normal map to be used for the :ref:`texture<class_Particles2D_property_texture>` property.
  185. \ **Note:** Godot expects the normal map to use X+, Y-, and Z+ coordinates. See `this page <http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates>`__ for a comparison of normal map coordinates expected by popular engines.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_Particles2D_property_one_shot:
  189. .. rst-class:: classref-property
  190. :ref:`bool<class_bool>` **one_shot** = ``false``
  191. .. rst-class:: classref-property-setget
  192. - void **set_one_shot** **(** :ref:`bool<class_bool>` value **)**
  193. - :ref:`bool<class_bool>` **get_one_shot** **(** **)**
  194. If ``true``, only one emission cycle occurs. If set ``true`` during a cycle, emission will stop at the cycle's end.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_Particles2D_property_preprocess:
  198. .. rst-class:: classref-property
  199. :ref:`float<class_float>` **preprocess** = ``0.0``
  200. .. rst-class:: classref-property-setget
  201. - void **set_pre_process_time** **(** :ref:`float<class_float>` value **)**
  202. - :ref:`float<class_float>` **get_pre_process_time** **(** **)**
  203. Particle system starts as if it had already run for this many seconds.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_Particles2D_property_process_material:
  207. .. rst-class:: classref-property
  208. :ref:`Material<class_Material>` **process_material**
  209. .. rst-class:: classref-property-setget
  210. - void **set_process_material** **(** :ref:`Material<class_Material>` value **)**
  211. - :ref:`Material<class_Material>` **get_process_material** **(** **)**
  212. :ref:`Material<class_Material>` for processing particles. Can be a :ref:`ParticlesMaterial<class_ParticlesMaterial>` or a :ref:`ShaderMaterial<class_ShaderMaterial>`.
  213. .. rst-class:: classref-item-separator
  214. ----
  215. .. _class_Particles2D_property_randomness:
  216. .. rst-class:: classref-property
  217. :ref:`float<class_float>` **randomness** = ``0.0``
  218. .. rst-class:: classref-property-setget
  219. - void **set_randomness_ratio** **(** :ref:`float<class_float>` value **)**
  220. - :ref:`float<class_float>` **get_randomness_ratio** **(** **)**
  221. Emission lifetime randomness ratio.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_Particles2D_property_speed_scale:
  225. .. rst-class:: classref-property
  226. :ref:`float<class_float>` **speed_scale** = ``1.0``
  227. .. rst-class:: classref-property-setget
  228. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  229. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  230. Particle system's running speed scaling ratio. A value of ``0`` can be used to pause the particles.
  231. .. rst-class:: classref-item-separator
  232. ----
  233. .. _class_Particles2D_property_texture:
  234. .. rst-class:: classref-property
  235. :ref:`Texture<class_Texture>` **texture**
  236. .. rst-class:: classref-property-setget
  237. - void **set_texture** **(** :ref:`Texture<class_Texture>` value **)**
  238. - :ref:`Texture<class_Texture>` **get_texture** **(** **)**
  239. Particle texture. If ``null``, particles will be squares.
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_Particles2D_property_visibility_rect:
  243. .. rst-class:: classref-property
  244. :ref:`Rect2<class_Rect2>` **visibility_rect** = ``Rect2( -100, -100, 200, 200 )``
  245. .. rst-class:: classref-property-setget
  246. - void **set_visibility_rect** **(** :ref:`Rect2<class_Rect2>` value **)**
  247. - :ref:`Rect2<class_Rect2>` **get_visibility_rect** **(** **)**
  248. The :ref:`Rect2<class_Rect2>` that determines the node's region which needs to be visible on screen for the particle system to be active.
  249. Grow the rect if particles suddenly appear/disappear when the node enters/exits the screen. The :ref:`Rect2<class_Rect2>` can be grown via code or with the **Particles → Generate Visibility Rect** editor tool.
  250. .. rst-class:: classref-section-separator
  251. ----
  252. .. rst-class:: classref-descriptions-group
  253. Method Descriptions
  254. -------------------
  255. .. _class_Particles2D_method_capture_rect:
  256. .. rst-class:: classref-method
  257. :ref:`Rect2<class_Rect2>` **capture_rect** **(** **)** |const|
  258. Returns a rectangle containing the positions of all existing particles.
  259. \ **Note:** When using threaded rendering this method synchronizes the rendering thread. Calling it often may have a negative impact on performance.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_Particles2D_method_restart:
  263. .. rst-class:: classref-method
  264. void **restart** **(** **)**
  265. Restarts all the existing particles.
  266. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  267. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  268. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  269. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`