mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
781 lines
41 KiB
ReStructuredText
781 lines
41 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. _class_GPUParticles2D:
|
||
|
||
GPUParticles2D
|
||
==============
|
||
|
||
**繼承:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
||
|
||
2D 粒子發射器。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
說明
|
||
----
|
||
|
||
2D 粒子節點,用於建立各種粒子系統和效果。\ **GPUParticles2D** 是一個發射器,特點是以給定的速度生成一定數量的粒子。
|
||
|
||
使用 :ref:`process_material<class_GPUParticles2D_property_process_material>` 屬性來新增一個配置粒子的外觀和行為的 :ref:`ParticleProcessMaterial<class_ParticleProcessMaterial>`\ 。或者,你可以新增一個套用於所有粒子的 :ref:`ShaderMaterial<class_ShaderMaterial>`\ 。
|
||
|
||
2D 粒子可以與 :ref:`LightOccluder2D<class_LightOccluder2D>` 節點碰撞(注意:它們不會與 :ref:`PhysicsBody2D<class_PhysicsBody2D>` 節點碰撞)。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
教學
|
||
----
|
||
|
||
- :doc:`粒子系統(2D) <../tutorials/2d/particle_systems_2d>`
|
||
|
||
- `2D 粒子演示 <https://godotengine.org/asset-library/asset/2724>`__
|
||
|
||
- `2D Dodge The Creeps 演示(玩家身後的拖尾使用的是 GPUParticles2D) <https://godotengine.org/asset-library/asset/2712>`__
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
屬性
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`amount<class_GPUParticles2D_property_amount>` | ``8`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`amount_ratio<class_GPUParticles2D_property_amount_ratio>` | ``1.0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`collision_base_size<class_GPUParticles2D_property_collision_base_size>` | ``1.0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`DrawOrder<enum_GPUParticles2D_DrawOrder>` | :ref:`draw_order<class_GPUParticles2D_property_draw_order>` | ``1`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`emitting<class_GPUParticles2D_property_emitting>` | ``true`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`explosiveness<class_GPUParticles2D_property_explosiveness>` | ``0.0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`fixed_fps<class_GPUParticles2D_property_fixed_fps>` | ``30`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`fract_delta<class_GPUParticles2D_property_fract_delta>` | ``true`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`interp_to_end<class_GPUParticles2D_property_interp_to_end>` | ``0.0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`interpolate<class_GPUParticles2D_property_interpolate>` | ``true`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`lifetime<class_GPUParticles2D_property_lifetime>` | ``1.0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`local_coords<class_GPUParticles2D_property_local_coords>` | ``false`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`one_shot<class_GPUParticles2D_property_one_shot>` | ``false`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`preprocess<class_GPUParticles2D_property_preprocess>` | ``0.0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`Material<class_Material>` | :ref:`process_material<class_GPUParticles2D_property_process_material>` | |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`randomness<class_GPUParticles2D_property_randomness>` | ``0.0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`seed<class_GPUParticles2D_property_seed>` | ``0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`speed_scale<class_GPUParticles2D_property_speed_scale>` | ``1.0`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`sub_emitter<class_GPUParticles2D_property_sub_emitter>` | ``NodePath("")`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`Texture2D<class_Texture2D>` | :ref:`texture<class_GPUParticles2D_property_texture>` | |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`trail_enabled<class_GPUParticles2D_property_trail_enabled>` | ``false`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`trail_lifetime<class_GPUParticles2D_property_trail_lifetime>` | ``0.3`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`trail_section_subdivisions<class_GPUParticles2D_property_trail_section_subdivisions>` | ``4`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`trail_sections<class_GPUParticles2D_property_trail_sections>` | ``8`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`use_fixed_seed<class_GPUParticles2D_property_use_fixed_seed>` | ``false`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
| :ref:`Rect2<class_Rect2>` | :ref:`visibility_rect<class_GPUParticles2D_property_visibility_rect>` | ``Rect2(-100, -100, 200, 200)`` |
|
||
+-------------------------------------------------+---------------------------------------------------------------------------------------------+---------------------------------+
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
方法
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Rect2<class_Rect2>` | :ref:`capture_rect<class_GPUParticles2D_method_capture_rect>`\ (\ ) |const| |
|
||
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`convert_from_particles<class_GPUParticles2D_method_convert_from_particles>`\ (\ particles\: :ref:`Node<class_Node>`\ ) |
|
||
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`emit_particle<class_GPUParticles2D_method_emit_particle>`\ (\ xform\: :ref:`Transform2D<class_Transform2D>`, velocity\: :ref:`Vector2<class_Vector2>`, color\: :ref:`Color<class_Color>`, custom\: :ref:`Color<class_Color>`, flags\: :ref:`int<class_int>`\ ) |
|
||
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`request_particles_process<class_GPUParticles2D_method_request_particles_process>`\ (\ process_time\: :ref:`float<class_float>`\ ) |
|
||
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`restart<class_GPUParticles2D_method_restart>`\ (\ keep_seed\: :ref:`bool<class_bool>` = false\ ) |
|
||
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
訊號
|
||
----
|
||
|
||
.. _class_GPUParticles2D_signal_finished:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**finished**\ (\ ) :ref:`🔗<class_GPUParticles2D_signal_finished>`
|
||
|
||
Emitted when all active particles have finished processing. To immediately restart the emission cycle, call :ref:`restart()<class_GPUParticles2D_method_restart>`.
|
||
|
||
This signal is never emitted when :ref:`one_shot<class_GPUParticles2D_property_one_shot>` is disabled, as particles will be emitted and processed continuously.
|
||
|
||
\ **Note:** For :ref:`one_shot<class_GPUParticles2D_property_one_shot>` emitters, due to the particles being computed on the GPU, there may be a short period after receiving the signal during which setting :ref:`emitting<class_GPUParticles2D_property_emitting>` to ``true`` will not restart the emission cycle. This delay is avoided by instead calling :ref:`restart()<class_GPUParticles2D_method_restart>`.
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
列舉
|
||
----
|
||
|
||
.. _enum_GPUParticles2D_DrawOrder:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **DrawOrder**: :ref:`🔗<enum_GPUParticles2D_DrawOrder>`
|
||
|
||
.. _class_GPUParticles2D_constant_DRAW_ORDER_INDEX:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DrawOrder<enum_GPUParticles2D_DrawOrder>` **DRAW_ORDER_INDEX** = ``0``
|
||
|
||
粒子按發射順序繪製。
|
||
|
||
.. _class_GPUParticles2D_constant_DRAW_ORDER_LIFETIME:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DrawOrder<enum_GPUParticles2D_DrawOrder>` **DRAW_ORDER_LIFETIME** = ``1``
|
||
|
||
Particles are drawn in order of remaining lifetime. In other words, the particle with the highest lifetime is drawn at the front.
|
||
|
||
.. _class_GPUParticles2D_constant_DRAW_ORDER_REVERSE_LIFETIME:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DrawOrder<enum_GPUParticles2D_DrawOrder>` **DRAW_ORDER_REVERSE_LIFETIME** = ``2``
|
||
|
||
Particles are drawn in reverse order of remaining lifetime. In other words, the particle with the lowest lifetime is drawn at the front.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_GPUParticles2D_EmitFlags:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **EmitFlags**: :ref:`🔗<enum_GPUParticles2D_EmitFlags>`
|
||
|
||
.. _class_GPUParticles2D_constant_EMIT_FLAG_POSITION:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`EmitFlags<enum_GPUParticles2D_EmitFlags>` **EMIT_FLAG_POSITION** = ``1``
|
||
|
||
粒子在指定位置開始。
|
||
|
||
.. _class_GPUParticles2D_constant_EMIT_FLAG_ROTATION_SCALE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`EmitFlags<enum_GPUParticles2D_EmitFlags>` **EMIT_FLAG_ROTATION_SCALE** = ``2``
|
||
|
||
粒子以指定的旋轉和縮放開始。
|
||
|
||
.. _class_GPUParticles2D_constant_EMIT_FLAG_VELOCITY:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`EmitFlags<enum_GPUParticles2D_EmitFlags>` **EMIT_FLAG_VELOCITY** = ``4``
|
||
|
||
粒子從指定的速度向量開始,該向量定義了發射方向和速度。
|
||
|
||
.. _class_GPUParticles2D_constant_EMIT_FLAG_COLOR:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`EmitFlags<enum_GPUParticles2D_EmitFlags>` **EMIT_FLAG_COLOR** = ``8``
|
||
|
||
粒子以指定的顏色開始。
|
||
|
||
.. _class_GPUParticles2D_constant_EMIT_FLAG_CUSTOM:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`EmitFlags<enum_GPUParticles2D_EmitFlags>` **EMIT_FLAG_CUSTOM** = ``16``
|
||
|
||
粒子以指定的 ``CUSTOM`` 資料開始。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
屬性說明
|
||
--------
|
||
|
||
.. _class_GPUParticles2D_property_amount:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **amount** = ``8`` :ref:`🔗<class_GPUParticles2D_property_amount>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_amount**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_amount**\ (\ )
|
||
|
||
The number of particles to emit in one emission cycle. The effective emission rate is ``(amount * amount_ratio) / lifetime`` particles per second. Higher values will increase GPU requirements, even if not all particles are visible at a given time or if :ref:`amount_ratio<class_GPUParticles2D_property_amount_ratio>` is decreased.
|
||
|
||
\ **Note:** Changing this value will cause the particle system to restart. To avoid this, change :ref:`amount_ratio<class_GPUParticles2D_property_amount_ratio>` instead.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_amount_ratio:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **amount_ratio** = ``1.0`` :ref:`🔗<class_GPUParticles2D_property_amount_ratio>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_amount_ratio**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_amount_ratio**\ (\ )
|
||
|
||
The ratio of particles that should actually be emitted. If set to a value lower than ``1.0``, this will set the amount of emitted particles throughout the lifetime to ``amount * amount_ratio``. Unlike changing :ref:`amount<class_GPUParticles2D_property_amount>`, changing :ref:`amount_ratio<class_GPUParticles2D_property_amount_ratio>` while emitting does not affect already-emitted particles and doesn't cause the particle system to restart. :ref:`amount_ratio<class_GPUParticles2D_property_amount_ratio>` can be used to create effects that make the number of emitted particles vary over time.
|
||
|
||
\ **Note:** Reducing the :ref:`amount_ratio<class_GPUParticles2D_property_amount_ratio>` has no performance benefit, since resources need to be allocated and processed for the total :ref:`amount<class_GPUParticles2D_property_amount>` of particles regardless of the :ref:`amount_ratio<class_GPUParticles2D_property_amount_ratio>`. If you don't intend to change the number of particles emitted while the particles are emitting, make sure :ref:`amount_ratio<class_GPUParticles2D_property_amount_ratio>` is set to ``1`` and change :ref:`amount<class_GPUParticles2D_property_amount>` to your liking instead.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_collision_base_size:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **collision_base_size** = ``1.0`` :ref:`🔗<class_GPUParticles2D_property_collision_base_size>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_collision_base_size**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_collision_base_size**\ (\ )
|
||
|
||
Multiplier for particle's collision radius. ``1.0`` corresponds to the size of the sprite. If particles appear to sink into the ground when colliding, increase this value. If particles appear to float when colliding, decrease this value. Only effective if :ref:`ParticleProcessMaterial.collision_mode<class_ParticleProcessMaterial_property_collision_mode>` is :ref:`ParticleProcessMaterial.COLLISION_RIGID<class_ParticleProcessMaterial_constant_COLLISION_RIGID>` or :ref:`ParticleProcessMaterial.COLLISION_HIDE_ON_CONTACT<class_ParticleProcessMaterial_constant_COLLISION_HIDE_ON_CONTACT>`.
|
||
|
||
\ **Note:** Particles always have a spherical collision shape.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_draw_order:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`DrawOrder<enum_GPUParticles2D_DrawOrder>` **draw_order** = ``1`` :ref:`🔗<class_GPUParticles2D_property_draw_order>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_draw_order**\ (\ value\: :ref:`DrawOrder<enum_GPUParticles2D_DrawOrder>`\ )
|
||
- :ref:`DrawOrder<enum_GPUParticles2D_DrawOrder>` **get_draw_order**\ (\ )
|
||
|
||
Particle draw order.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_emitting:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **emitting** = ``true`` :ref:`🔗<class_GPUParticles2D_property_emitting>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_emitting**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_emitting**\ (\ )
|
||
|
||
If ``true``, particles are being emitted. :ref:`emitting<class_GPUParticles2D_property_emitting>` can be used to start and stop particles from emitting. However, if :ref:`one_shot<class_GPUParticles2D_property_one_shot>` is ``true`` setting :ref:`emitting<class_GPUParticles2D_property_emitting>` to ``true`` will not restart the emission cycle unless all active particles have finished processing. Use the :ref:`finished<class_GPUParticles2D_signal_finished>` signal to be notified once all active particles finish processing.
|
||
|
||
\ **Note:** For :ref:`one_shot<class_GPUParticles2D_property_one_shot>` emitters, due to the particles being computed on the GPU, there may be a short period after receiving the :ref:`finished<class_GPUParticles2D_signal_finished>` signal during which setting this to ``true`` will not restart the emission cycle.
|
||
|
||
\ **Tip:** If your :ref:`one_shot<class_GPUParticles2D_property_one_shot>` emitter needs to immediately restart emitting particles once :ref:`finished<class_GPUParticles2D_signal_finished>` signal is received, consider calling :ref:`restart()<class_GPUParticles2D_method_restart>` instead of setting :ref:`emitting<class_GPUParticles2D_property_emitting>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_explosiveness:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **explosiveness** = ``0.0`` :ref:`🔗<class_GPUParticles2D_property_explosiveness>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_explosiveness_ratio**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_explosiveness_ratio**\ (\ )
|
||
|
||
粒子在單個發射週期中的發射有多急。如果大於 ``0``\ ,則在下一個發射週期開始之前,發射會出現一個間隔。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_fixed_fps:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **fixed_fps** = ``30`` :ref:`🔗<class_GPUParticles2D_property_fixed_fps>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_fixed_fps**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_fixed_fps**\ (\ )
|
||
|
||
粒子系統的畫面播放速率被固定為一個值。例如,將值更改為 2 會使粒子以每秒 2 影格的速度算繪。請注意,這並不會降低粒子系統本身的類比速度。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_fract_delta:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **fract_delta** = ``true`` :ref:`🔗<class_GPUParticles2D_property_fract_delta>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_fractional_delta**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **get_fractional_delta**\ (\ )
|
||
|
||
如果為 ``為true``\ ,則使用分數差異量 delta 計算,將具有更平滑的粒子顯示效果。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_interp_to_end:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **interp_to_end** = ``0.0`` :ref:`🔗<class_GPUParticles2D_property_interp_to_end>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_interp_to_end**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_interp_to_end**\ (\ )
|
||
|
||
Causes all the particles in this node to interpolate towards the end of their lifetime.
|
||
|
||
\ **Note:** This only works when used with a :ref:`ParticleProcessMaterial<class_ParticleProcessMaterial>`. It needs to be manually implemented for custom process shaders.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_interpolate:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **interpolate** = ``true`` :ref:`🔗<class_GPUParticles2D_property_interpolate>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_interpolate**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **get_interpolate**\ (\ )
|
||
|
||
啟用粒子插值,當\ :ref:`fixed_fps<class_GPUParticles2D_property_fixed_fps>` 低於螢幕更新率時,使粒子運動更平滑。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_lifetime:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **lifetime** = ``1.0`` :ref:`🔗<class_GPUParticles2D_property_lifetime>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_lifetime**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_lifetime**\ (\ )
|
||
|
||
The amount of time each particle will exist (in seconds). The effective emission rate is ``(amount * amount_ratio) / lifetime`` particles per second.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_local_coords:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **local_coords** = ``false`` :ref:`🔗<class_GPUParticles2D_property_local_coords>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_use_local_coordinates**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **get_use_local_coordinates**\ (\ )
|
||
|
||
如果為 ``true``\ ,則粒子使用父節點的座標空間(稱為局部座標)。這將導致粒子在移動或旋轉時沿著 **GPUParticles2D** 節點(及其父節點)移動和旋轉。如果為 ``false``\ ,則粒子使用全域座標;當移動或旋轉時,它們不會沿著 **GPUParticles2D** 節點(及其父節點)移動或旋轉。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_one_shot:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **one_shot** = ``false`` :ref:`🔗<class_GPUParticles2D_property_one_shot>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_one_shot**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **get_one_shot**\ (\ )
|
||
|
||
如果為 ``true``\ ,則只發生一個發射週期。如果在某個週期內設定為 ``true``\ ,則發射將在該週期結束時停止。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_preprocess:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **preprocess** = ``0.0`` :ref:`🔗<class_GPUParticles2D_property_preprocess>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_pre_process_time**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_pre_process_time**\ (\ )
|
||
|
||
Particle system starts as if it had already run for this many seconds.
|
||
|
||
\ **Note:** This can be very expensive if set to a high number as it requires running the particle shader a number of times equal to the :ref:`fixed_fps<class_GPUParticles2D_property_fixed_fps>` (or 30, if :ref:`fixed_fps<class_GPUParticles2D_property_fixed_fps>` is 0) for every second. In extreme cases it can even lead to a GPU crash due to the volume of work done in a single frame.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_process_material:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Material<class_Material>` **process_material** :ref:`🔗<class_GPUParticles2D_property_process_material>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_process_material**\ (\ value\: :ref:`Material<class_Material>`\ )
|
||
- :ref:`Material<class_Material>` **get_process_material**\ (\ )
|
||
|
||
用於處理粒子的 :ref:`Material<class_Material>` 。可以是 :ref:`ParticleProcessMaterial<class_ParticleProcessMaterial>` 或 :ref:`ShaderMaterial<class_ShaderMaterial>` 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_randomness:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **randomness** = ``0.0`` :ref:`🔗<class_GPUParticles2D_property_randomness>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_randomness_ratio**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_randomness_ratio**\ (\ )
|
||
|
||
發射壽命隨機率。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_seed:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **seed** = ``0`` :ref:`🔗<class_GPUParticles2D_property_seed>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_seed**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_seed**\ (\ )
|
||
|
||
Sets the random seed used by the particle system. Only effective if :ref:`use_fixed_seed<class_GPUParticles2D_property_use_fixed_seed>` is ``true``.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_speed_scale:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **speed_scale** = ``1.0`` :ref:`🔗<class_GPUParticles2D_property_speed_scale>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_speed_scale**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_speed_scale**\ (\ )
|
||
|
||
粒子系統的運作速度的縮放率。\ ``0`` 值可用於暫停粒子。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_sub_emitter:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`NodePath<class_NodePath>` **sub_emitter** = ``NodePath("")`` :ref:`🔗<class_GPUParticles2D_property_sub_emitter>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_sub_emitter**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
|
||
- :ref:`NodePath<class_NodePath>` **get_sub_emitter**\ (\ )
|
||
|
||
Path to another **GPUParticles2D** node that will be used as a subemitter (see :ref:`ParticleProcessMaterial.sub_emitter_mode<class_ParticleProcessMaterial_property_sub_emitter_mode>`). Subemitters can be used to achieve effects such as fireworks, sparks on collision, bubbles popping into water drops, and more.
|
||
|
||
\ **Note:** When :ref:`sub_emitter<class_GPUParticles2D_property_sub_emitter>` is set, the target **GPUParticles2D** node will no longer emit particles on its own.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_texture:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Texture2D<class_Texture2D>` **texture** :ref:`🔗<class_GPUParticles2D_property_texture>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_texture**\ (\ value\: :ref:`Texture2D<class_Texture2D>`\ )
|
||
- :ref:`Texture2D<class_Texture2D>` **get_texture**\ (\ )
|
||
|
||
Particle texture. If ``null``, particles will be squares with a size of 1×1 pixels.
|
||
|
||
\ **Note:** To use a flipbook texture, assign a new :ref:`CanvasItemMaterial<class_CanvasItemMaterial>` to the **GPUParticles2D**'s :ref:`CanvasItem.material<class_CanvasItem_property_material>` property, then enable :ref:`CanvasItemMaterial.particles_animation<class_CanvasItemMaterial_property_particles_animation>` and set :ref:`CanvasItemMaterial.particles_anim_h_frames<class_CanvasItemMaterial_property_particles_anim_h_frames>`, :ref:`CanvasItemMaterial.particles_anim_v_frames<class_CanvasItemMaterial_property_particles_anim_v_frames>`, and :ref:`CanvasItemMaterial.particles_anim_loop<class_CanvasItemMaterial_property_particles_anim_loop>` to match the flipbook texture.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_trail_enabled:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **trail_enabled** = ``false`` :ref:`🔗<class_GPUParticles2D_property_trail_enabled>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_trail_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_trail_enabled**\ (\ )
|
||
|
||
如果\ ``true`` ,可以使用網格換膚系統來啟用粒子軌跡。
|
||
|
||
\ **注意:**\ 與\ :ref:`GPUParticles3D<class_GPUParticles3D>`\ 不同的是,trail sections和subdivisions的數量是通過屬性\ :ref:`trail_sections<class_GPUParticles2D_property_trail_sections>`\ 和\ :ref:`trail_section_subdivisions<class_GPUParticles2D_property_trail_section_subdivisions>`\ 設定的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_trail_lifetime:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **trail_lifetime** = ``0.3`` :ref:`🔗<class_GPUParticles2D_property_trail_lifetime>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_trail_lifetime**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_trail_lifetime**\ (\ )
|
||
|
||
代表粒子軌跡的時間量(以秒為單位)。僅當 :ref:`trail_enabled<class_GPUParticles2D_property_trail_enabled>` 為 ``true`` 時有效。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_trail_section_subdivisions:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **trail_section_subdivisions** = ``4`` :ref:`🔗<class_GPUParticles2D_property_trail_section_subdivisions>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_trail_section_subdivisions**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_trail_section_subdivisions**\ (\ )
|
||
|
||
用於粒子尾跡算繪的細分數。較高的值可以產生更平滑的尾跡曲線,但由於增加了網格的複雜度,因此會犧牲性能。另見 :ref:`trail_sections<class_GPUParticles2D_property_trail_sections>`\ 。僅當 :ref:`trail_enabled<class_GPUParticles2D_property_trail_enabled>` 為 ``true`` 時有效。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_trail_sections:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **trail_sections** = ``8`` :ref:`🔗<class_GPUParticles2D_property_trail_sections>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_trail_sections**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_trail_sections**\ (\ )
|
||
|
||
用於粒子軌跡算繪的部分數。較高的值可以產生更平滑的尾跡曲線,但由於增加了網格的複雜度,因此會犧牲性能。另見 :ref:`trail_section_subdivisions<class_GPUParticles2D_property_trail_section_subdivisions>`\ 。僅當 :ref:`trail_enabled<class_GPUParticles2D_property_trail_enabled>` 為 ``true`` 時有效。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_use_fixed_seed:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **use_fixed_seed** = ``false`` :ref:`🔗<class_GPUParticles2D_property_use_fixed_seed>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_use_fixed_seed**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **get_use_fixed_seed**\ (\ )
|
||
|
||
If ``true``, particles will use the same seed for every simulation using the seed defined in :ref:`seed<class_GPUParticles2D_property_seed>`. This is useful for situations where the visual outcome should be consistent across replays, for example when using Movie Maker mode.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_property_visibility_rect:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Rect2<class_Rect2>` **visibility_rect** = ``Rect2(-100, -100, 200, 200)`` :ref:`🔗<class_GPUParticles2D_property_visibility_rect>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_visibility_rect**\ (\ value\: :ref:`Rect2<class_Rect2>`\ )
|
||
- :ref:`Rect2<class_Rect2>` **get_visibility_rect**\ (\ )
|
||
|
||
:ref:`Rect2<class_Rect2>` 確定節點的區域,該區域需要在螢幕上可見才能使粒子系統處於活動狀態。
|
||
|
||
如果當節點進入/退出螢幕時粒子突然出現/消失,則增長矩形。\ :ref:`Rect2<class_Rect2>` 可以通過程式碼或使用 **Particles → Generate Visibility Rect** 編輯器工具生成。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
方法說明
|
||
--------
|
||
|
||
.. _class_GPUParticles2D_method_capture_rect:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Rect2<class_Rect2>` **capture_rect**\ (\ ) |const| :ref:`🔗<class_GPUParticles2D_method_capture_rect>`
|
||
|
||
傳回一個包含所有現有粒子位置的矩形。
|
||
|
||
\ **注意:** 當使用執行緒算繪時,此方法會同步算繪執行緒。經常呼叫可能會對效能產生負面影響。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_method_convert_from_particles:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **convert_from_particles**\ (\ particles\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_GPUParticles2D_method_convert_from_particles>`
|
||
|
||
設定該節點的屬性以配對給定的 **GPUParticles2D** 節點,該給定節點已分配了一個 :ref:`ParticleProcessMaterial<class_ParticleProcessMaterial>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_method_emit_particle:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **emit_particle**\ (\ xform\: :ref:`Transform2D<class_Transform2D>`, velocity\: :ref:`Vector2<class_Vector2>`, color\: :ref:`Color<class_Color>`, custom\: :ref:`Color<class_Color>`, flags\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GPUParticles2D_method_emit_particle>`
|
||
|
||
Emits a single particle. Whether ``xform``, ``velocity``, ``color`` and ``custom`` are applied depends on the value of ``flags``. See :ref:`EmitFlags<enum_GPUParticles2D_EmitFlags>`.
|
||
|
||
The default ParticleProcessMaterial will overwrite ``color`` and use the contents of ``custom`` as ``(rotation, age, animation, lifetime)``.
|
||
|
||
\ **Note:** :ref:`emit_particle()<class_GPUParticles2D_method_emit_particle>` is only supported on the Forward+ and Mobile rendering methods, not Compatibility.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_method_request_particles_process:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **request_particles_process**\ (\ process_time\: :ref:`float<class_float>`\ ) :ref:`🔗<class_GPUParticles2D_method_request_particles_process>`
|
||
|
||
Requests the particles to process for extra process time during a single frame.
|
||
|
||
Useful for particle playback, if used in combination with :ref:`use_fixed_seed<class_GPUParticles2D_property_use_fixed_seed>` or by calling :ref:`restart()<class_GPUParticles2D_method_restart>` with parameter ``keep_seed`` set to ``true``.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_GPUParticles2D_method_restart:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **restart**\ (\ keep_seed\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_GPUParticles2D_method_restart>`
|
||
|
||
Restarts the particle emission cycle, clearing existing particles. To avoid particles vanishing from the viewport, wait for the :ref:`finished<class_GPUParticles2D_signal_finished>` signal before calling.
|
||
|
||
\ **Note:** The :ref:`finished<class_GPUParticles2D_signal_finished>` signal is only emitted by :ref:`one_shot<class_GPUParticles2D_property_one_shot>` emitters.
|
||
|
||
If ``keep_seed`` is ``true``, the current random seed will be preserved. Useful for seeking and playback.
|
||
|
||
.. |virtual| replace:: :abbr:`virtual (本方法通常需要使用者覆寫才能生效。)`
|
||
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
||
.. |const| replace:: :abbr:`const (本方法沒有副作用。不會修改該實例的任何成員變數。)`
|
||
.. |vararg| replace:: :abbr:`vararg (本方法除了這裡描述的參數外,還可以接受任意數量的參數。)`
|
||
.. |constructor| replace:: :abbr:`constructor (本方法用於建構一個型別。)`
|
||
.. |static| replace:: :abbr:`static (本方法無需實例即可呼叫,因此可以直接使用類別名稱呼叫。)`
|
||
.. |operator| replace:: :abbr:`operator (本方法描述將本型別作為左運算元時可用的有效運算子。)`
|
||
.. |bitfield| replace:: :abbr:`BitField (此值是由下列旗標組成的位元遮罩整數。)`
|
||
.. |void| replace:: :abbr:`void (無回傳值。)`
|