class_particles2d.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Particles2D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Particles2D:
  6. Particles2D
  7. ===========
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. GPU-based 2D particle emitter.
  10. Description
  11. -----------
  12. 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.
  13. 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.
  14. **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**.
  15. **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.
  16. **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.
  17. **Note:** Unlike :ref:`CPUParticles2D<class_CPUParticles2D>`, ``Particles2D`` currently ignore the texture region defined in :ref:`AtlasTexture<class_AtlasTexture>`\ s.
  18. Tutorials
  19. ---------
  20. - :doc:`../tutorials/2d/particle_systems_2d`
  21. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  22. Properties
  23. ----------
  24. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  25. | :ref:`int<class_int>` | :ref:`amount<class_Particles2D_property_amount>` | ``8`` |
  26. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  27. | :ref:`DrawOrder<enum_Particles2D_DrawOrder>` | :ref:`draw_order<class_Particles2D_property_draw_order>` | ``0`` |
  28. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`emitting<class_Particles2D_property_emitting>` | ``true`` |
  30. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  31. | :ref:`float<class_float>` | :ref:`explosiveness<class_Particles2D_property_explosiveness>` | ``0.0`` |
  32. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  33. | :ref:`int<class_int>` | :ref:`fixed_fps<class_Particles2D_property_fixed_fps>` | ``0`` |
  34. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`fract_delta<class_Particles2D_property_fract_delta>` | ``true`` |
  36. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  37. | :ref:`float<class_float>` | :ref:`lifetime<class_Particles2D_property_lifetime>` | ``1.0`` |
  38. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`local_coords<class_Particles2D_property_local_coords>` | ``true`` |
  40. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  41. | :ref:`Texture<class_Texture>` | :ref:`normal_map<class_Particles2D_property_normal_map>` | |
  42. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`one_shot<class_Particles2D_property_one_shot>` | ``false`` |
  44. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  45. | :ref:`float<class_float>` | :ref:`preprocess<class_Particles2D_property_preprocess>` | ``0.0`` |
  46. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  47. | :ref:`Material<class_Material>` | :ref:`process_material<class_Particles2D_property_process_material>` | |
  48. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  49. | :ref:`float<class_float>` | :ref:`randomness<class_Particles2D_property_randomness>` | ``0.0`` |
  50. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  51. | :ref:`float<class_float>` | :ref:`speed_scale<class_Particles2D_property_speed_scale>` | ``1.0`` |
  52. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  53. | :ref:`Texture<class_Texture>` | :ref:`texture<class_Particles2D_property_texture>` | |
  54. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  55. | :ref:`Rect2<class_Rect2>` | :ref:`visibility_rect<class_Particles2D_property_visibility_rect>` | ``Rect2( -100, -100, 200, 200 )`` |
  56. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------+
  57. Methods
  58. -------
  59. +---------------------------+--------------------------------------------------------------------------------+
  60. | :ref:`Rect2<class_Rect2>` | :ref:`capture_rect<class_Particles2D_method_capture_rect>` **(** **)** |const| |
  61. +---------------------------+--------------------------------------------------------------------------------+
  62. | void | :ref:`restart<class_Particles2D_method_restart>` **(** **)** |
  63. +---------------------------+--------------------------------------------------------------------------------+
  64. Enumerations
  65. ------------
  66. .. _enum_Particles2D_DrawOrder:
  67. .. _class_Particles2D_constant_DRAW_ORDER_INDEX:
  68. .. _class_Particles2D_constant_DRAW_ORDER_LIFETIME:
  69. enum **DrawOrder**:
  70. - **DRAW_ORDER_INDEX** = **0** --- Particles are drawn in the order emitted.
  71. - **DRAW_ORDER_LIFETIME** = **1** --- Particles are drawn in order of remaining lifetime.
  72. Property Descriptions
  73. ---------------------
  74. .. _class_Particles2D_property_amount:
  75. - :ref:`int<class_int>` **amount**
  76. +-----------+-------------------+
  77. | *Default* | ``8`` |
  78. +-----------+-------------------+
  79. | *Setter* | set_amount(value) |
  80. +-----------+-------------------+
  81. | *Getter* | get_amount() |
  82. +-----------+-------------------+
  83. The number of particles emitted in one emission cycle (corresponding to the :ref:`lifetime<class_Particles2D_property_lifetime>`).
  84. **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>`.
  85. ----
  86. .. _class_Particles2D_property_draw_order:
  87. - :ref:`DrawOrder<enum_Particles2D_DrawOrder>` **draw_order**
  88. +-----------+-----------------------+
  89. | *Default* | ``0`` |
  90. +-----------+-----------------------+
  91. | *Setter* | set_draw_order(value) |
  92. +-----------+-----------------------+
  93. | *Getter* | get_draw_order() |
  94. +-----------+-----------------------+
  95. Particle draw order. Uses :ref:`DrawOrder<enum_Particles2D_DrawOrder>` values.
  96. ----
  97. .. _class_Particles2D_property_emitting:
  98. - :ref:`bool<class_bool>` **emitting**
  99. +-----------+---------------------+
  100. | *Default* | ``true`` |
  101. +-----------+---------------------+
  102. | *Setter* | set_emitting(value) |
  103. +-----------+---------------------+
  104. | *Getter* | is_emitting() |
  105. +-----------+---------------------+
  106. If ``true``, particles are being emitted.
  107. ----
  108. .. _class_Particles2D_property_explosiveness:
  109. - :ref:`float<class_float>` **explosiveness**
  110. +-----------+--------------------------------+
  111. | *Default* | ``0.0`` |
  112. +-----------+--------------------------------+
  113. | *Setter* | set_explosiveness_ratio(value) |
  114. +-----------+--------------------------------+
  115. | *Getter* | get_explosiveness_ratio() |
  116. +-----------+--------------------------------+
  117. 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.
  118. ----
  119. .. _class_Particles2D_property_fixed_fps:
  120. - :ref:`int<class_int>` **fixed_fps**
  121. +-----------+----------------------+
  122. | *Default* | ``0`` |
  123. +-----------+----------------------+
  124. | *Setter* | set_fixed_fps(value) |
  125. +-----------+----------------------+
  126. | *Getter* | get_fixed_fps() |
  127. +-----------+----------------------+
  128. 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.
  129. ----
  130. .. _class_Particles2D_property_fract_delta:
  131. - :ref:`bool<class_bool>` **fract_delta**
  132. +-----------+-----------------------------+
  133. | *Default* | ``true`` |
  134. +-----------+-----------------------------+
  135. | *Setter* | set_fractional_delta(value) |
  136. +-----------+-----------------------------+
  137. | *Getter* | get_fractional_delta() |
  138. +-----------+-----------------------------+
  139. If ``true``, results in fractional delta calculation which has a smoother particles display effect.
  140. ----
  141. .. _class_Particles2D_property_lifetime:
  142. - :ref:`float<class_float>` **lifetime**
  143. +-----------+---------------------+
  144. | *Default* | ``1.0`` |
  145. +-----------+---------------------+
  146. | *Setter* | set_lifetime(value) |
  147. +-----------+---------------------+
  148. | *Getter* | get_lifetime() |
  149. +-----------+---------------------+
  150. The amount of time each particle will exist (in seconds).
  151. ----
  152. .. _class_Particles2D_property_local_coords:
  153. - :ref:`bool<class_bool>` **local_coords**
  154. +-----------+----------------------------------+
  155. | *Default* | ``true`` |
  156. +-----------+----------------------------------+
  157. | *Setter* | set_use_local_coordinates(value) |
  158. +-----------+----------------------------------+
  159. | *Getter* | get_use_local_coordinates() |
  160. +-----------+----------------------------------+
  161. If ``true``, particles use the parent node's coordinate space. If ``false``, they use global coordinates.
  162. ----
  163. .. _class_Particles2D_property_normal_map:
  164. - :ref:`Texture<class_Texture>` **normal_map**
  165. +----------+-----------------------+
  166. | *Setter* | set_normal_map(value) |
  167. +----------+-----------------------+
  168. | *Getter* | get_normal_map() |
  169. +----------+-----------------------+
  170. Normal map to be used for the :ref:`texture<class_Particles2D_property_texture>` property.
  171. **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.
  172. ----
  173. .. _class_Particles2D_property_one_shot:
  174. - :ref:`bool<class_bool>` **one_shot**
  175. +-----------+---------------------+
  176. | *Default* | ``false`` |
  177. +-----------+---------------------+
  178. | *Setter* | set_one_shot(value) |
  179. +-----------+---------------------+
  180. | *Getter* | get_one_shot() |
  181. +-----------+---------------------+
  182. If ``true``, only one emission cycle occurs. If set ``true`` during a cycle, emission will stop at the cycle's end.
  183. ----
  184. .. _class_Particles2D_property_preprocess:
  185. - :ref:`float<class_float>` **preprocess**
  186. +-----------+-----------------------------+
  187. | *Default* | ``0.0`` |
  188. +-----------+-----------------------------+
  189. | *Setter* | set_pre_process_time(value) |
  190. +-----------+-----------------------------+
  191. | *Getter* | get_pre_process_time() |
  192. +-----------+-----------------------------+
  193. Particle system starts as if it had already run for this many seconds.
  194. ----
  195. .. _class_Particles2D_property_process_material:
  196. - :ref:`Material<class_Material>` **process_material**
  197. +----------+-----------------------------+
  198. | *Setter* | set_process_material(value) |
  199. +----------+-----------------------------+
  200. | *Getter* | get_process_material() |
  201. +----------+-----------------------------+
  202. :ref:`Material<class_Material>` for processing particles. Can be a :ref:`ParticlesMaterial<class_ParticlesMaterial>` or a :ref:`ShaderMaterial<class_ShaderMaterial>`.
  203. ----
  204. .. _class_Particles2D_property_randomness:
  205. - :ref:`float<class_float>` **randomness**
  206. +-----------+-----------------------------+
  207. | *Default* | ``0.0`` |
  208. +-----------+-----------------------------+
  209. | *Setter* | set_randomness_ratio(value) |
  210. +-----------+-----------------------------+
  211. | *Getter* | get_randomness_ratio() |
  212. +-----------+-----------------------------+
  213. Emission lifetime randomness ratio.
  214. ----
  215. .. _class_Particles2D_property_speed_scale:
  216. - :ref:`float<class_float>` **speed_scale**
  217. +-----------+------------------------+
  218. | *Default* | ``1.0`` |
  219. +-----------+------------------------+
  220. | *Setter* | set_speed_scale(value) |
  221. +-----------+------------------------+
  222. | *Getter* | get_speed_scale() |
  223. +-----------+------------------------+
  224. Particle system's running speed scaling ratio. A value of ``0`` can be used to pause the particles.
  225. ----
  226. .. _class_Particles2D_property_texture:
  227. - :ref:`Texture<class_Texture>` **texture**
  228. +----------+--------------------+
  229. | *Setter* | set_texture(value) |
  230. +----------+--------------------+
  231. | *Getter* | get_texture() |
  232. +----------+--------------------+
  233. Particle texture. If ``null``, particles will be squares.
  234. ----
  235. .. _class_Particles2D_property_visibility_rect:
  236. - :ref:`Rect2<class_Rect2>` **visibility_rect**
  237. +-----------+-----------------------------------+
  238. | *Default* | ``Rect2( -100, -100, 200, 200 )`` |
  239. +-----------+-----------------------------------+
  240. | *Setter* | set_visibility_rect(value) |
  241. +-----------+-----------------------------------+
  242. | *Getter* | get_visibility_rect() |
  243. +-----------+-----------------------------------+
  244. 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.
  245. 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.
  246. Method Descriptions
  247. -------------------
  248. .. _class_Particles2D_method_capture_rect:
  249. - :ref:`Rect2<class_Rect2>` **capture_rect** **(** **)** |const|
  250. Returns a rectangle containing the positions of all existing particles.
  251. ----
  252. .. _class_Particles2D_method_restart:
  253. - void **restart** **(** **)**
  254. Restarts all the existing particles.
  255. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  256. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  257. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`