Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
CPUParticles2D
繼承: Node2D < CanvasItem < Node < Object
基於 CPU 的 2D 粒子發射器。
說明
基於 CPU 的 2D 粒子節點,可用於建立各種粒子系統、粒子效果。
另見 GPUParticles2D,利用硬體加速提供了相同的功能,但可能無法在較舊的裝置上運作。
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
physics_interpolation_mode |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
convert_from_particles(particles: Node) |
get_param_curve(param: Parameter) const |
|
get_param_max(param: Parameter) const |
|
get_param_min(param: Parameter) const |
|
get_particle_flag(particle_flag: ParticleFlags) const |
|
void |
request_particles_process(process_time: float, process_time_residual: float = 0.0) |
void |
|
void |
set_param_curve(param: Parameter, curve: Curve) |
void |
set_param_max(param: Parameter, value: float) |
void |
set_param_min(param: Parameter, value: float) |
void |
set_particle_flag(particle_flag: ParticleFlags, enable: bool) |
訊號
finished() 🔗
所有活動粒子完成處理時發出。當 one_shot 停用時,粒子將連續處理,因此永遠不會發出。
列舉
enum DrawOrder: 🔗
DrawOrder DRAW_ORDER_INDEX = 0
粒子按發射順序繪製。
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.
enum Parameter: 🔗
Parameter PARAM_INITIAL_LINEAR_VELOCITY = 0
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定初始速度屬性。
Parameter PARAM_ANGULAR_VELOCITY = 1
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定角速度屬性。
Parameter PARAM_ORBIT_VELOCITY = 2
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定軌道速度屬性。
Parameter PARAM_LINEAR_ACCEL = 3
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定線性加速度屬性。
Parameter PARAM_RADIAL_ACCEL = 4
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定徑向加速度屬性。
Parameter PARAM_TANGENTIAL_ACCEL = 5
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定切向加速度屬性。
Parameter PARAM_DAMPING = 6
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定阻尼屬性。
Parameter PARAM_ANGLE = 7
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定角度屬性。
Parameter PARAM_SCALE = 8
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定縮放屬性。
Parameter PARAM_HUE_VARIATION = 9
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定色相變化屬性。
Parameter PARAM_ANIM_SPEED = 10
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定動畫速度屬性。
Parameter PARAM_ANIM_OFFSET = 11
與 set_param_min()、set_param_max()、set_param_curve() 一起使用,設定動畫偏移屬性。
Parameter PARAM_MAX = 12
代表 Parameter 列舉的大小。
enum ParticleFlags: 🔗
ParticleFlags PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY = 0
與 set_particle_flag() 一起使用,設定 particle_flag_align_y。
ParticleFlags PARTICLE_FLAG_ROTATE_Y = 1
為了與 3D 粒子節點保持一致而存在,在 2D 中不被使用。
ParticleFlags PARTICLE_FLAG_DISABLE_Z = 2
為了與 3D 粒子節點保持一致而存在,在 2D 中不被使用。
ParticleFlags PARTICLE_FLAG_MAX = 3
代表 ParticleFlags 列舉的大小。
enum EmissionShape: 🔗
EmissionShape EMISSION_SHAPE_POINT = 0
所有粒子將從單個點發射。
EmissionShape EMISSION_SHAPE_SPHERE = 1
粒子將在扁平化到二維的球體內發射。
EmissionShape EMISSION_SHAPE_SPHERE_SURFACE = 2
粒子將在扁平化到二維的球面上發射。
EmissionShape EMISSION_SHAPE_RECTANGLE = 3
粒子將在矩形區域內發射。
EmissionShape EMISSION_SHAPE_POINTS = 4
粒子將在 emission_points 中隨機選擇的位置發射。粒子顏色將通過 emission_colors 進行調變。
EmissionShape EMISSION_SHAPE_DIRECTED_POINTS = 5
粒子將在 emission_points 中隨機選擇的位置發射。粒子的速度和旋轉將基於 emission_normals 進行設定。粒子顏色將通過 emission_colors 進行調變。
EmissionShape EMISSION_SHAPE_RING = 6
Particles will be emitted in the area of a ring parameterized by its outer and inner radius.
EmissionShape EMISSION_SHAPE_MAX = 7
代表 EmissionShape 列舉的大小。
屬性說明
單個發射週期內發射的粒子數。
Each particle's rotation will be animated along this Curve. Should be a unit Curve.
套用於每個粒子的最大初始旋轉,單位:度。
angle_max 的對應最小值。
Curve angular_velocity_curve 🔗
Each particle's angular velocity will vary along this Curve. Should be a unit Curve.
float angular_velocity_max = 0.0 🔗
套用於每個粒子的最大初始角速度(旋轉速度),單位:度每秒。
float angular_velocity_min = 0.0 🔗
angular_velocity_max 的對應最小值。
Each particle's animation offset will vary along this Curve. Should be a unit Curve.
與紋理中的影格索引相對應的最大動畫偏移量。0 是第一影格,1 是最後一影格。參見 CanvasItemMaterial.particles_animation。
anim_offset_max 的對應最小值。
Each particle's animation speed will vary along this Curve. Should be a unit Curve.
最大粒子動畫速度。1 的動畫速度是指粒子在生命週期內會做完整的 0 到 1 的偏移迴圈,2 則表示 2 個迴圈,如此等等。
當動畫速度大於 1 時,如果希望動畫重複,請記住啟用 CanvasItemMaterial.particles_anim_loop 屬性。
anim_speed_max 的對應最小值。
Color color = Color(1, 1, 1, 1) 🔗
每個粒子的初始顏色。如果定義了 texture,它將乘以該顏色。
Each particle's initial color will vary along this Gradient (multiplied with color).
Each particle's color will vary along this Gradient over its lifetime (multiplied with color).
Damping will vary along this Curve. Should be a unit Curve.
粒子失去速度的最大速率。例如 100 的值表示粒子將在 1 秒內,速度從 100 變為 0。
damping_max 的對應最小值。
Vector2 direction = Vector2(1, 0) 🔗
指定粒子發射方向的單位向量。
Particle draw order.
PackedColorArray emission_colors 🔗
void set_emission_colors(value: PackedColorArray)
PackedColorArray get_emission_colors()
設定使用 EMISSION_SHAPE_POINTS 或 EMISSION_SHAPE_DIRECTED_POINTS 時對粒子進行調變的 Color。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedColorArray for more details.
PackedVector2Array emission_normals 🔗
void set_emission_normals(value: PackedVector2Array)
PackedVector2Array get_emission_normals()
設定使用 EMISSION_SHAPE_DIRECTED_POINTS 時粒子發射的方向。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedVector2Array for more details.
PackedVector2Array emission_points 🔗
void set_emission_points(value: PackedVector2Array)
PackedVector2Array get_emission_points()
設定使用 EMISSION_SHAPE_POINTS 或 EMISSION_SHAPE_DIRECTED_POINTS 時出生粒子的初始位置。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedVector2Array for more details.
Vector2 emission_rect_extents 🔗
emission_shape 被設定為 EMISSION_SHAPE_RECTANGLE 時,該矩形的範圍。
float emission_ring_inner_radius 🔗
The ring's inner radius if emission_shape is set to EMISSION_SHAPE_RING.
The ring's outer radius if emission_shape is set to EMISSION_SHAPE_RING.
EmissionShape emission_shape = 0 🔗
void set_emission_shape(value: EmissionShape)
EmissionShape get_emission_shape()
Particles will be emitted inside this region.
float emission_sphere_radius 🔗
emission_shape 被設定為 EMISSION_SHAPE_SPHERE 時,該球體的半徑。
如果 true,則正在發射粒子。emitting 可用於啟動和停止粒子發射。但是,如果 one_shot 為 true `` 將\ :ref:`emitting<class_CPUParticles2D_property_emitting>` 設為\ ``true 直到所有活動粒子完成處理後才會重新啟動發射週期。一旦所有活動粒子都完成,您可以使用finished 訊號來通知粒子完成處理。
粒子在單個發射週期中的發射有多急。如果大於 0,則在下一個發射週期開始之前,發射會出現一個間隔。
粒子系統的畫面播放速率被固定為一個值。例如,將值更改為 2 會使粒子以每秒 2 影格的速度算繪。請注意,這並不會降低粒子系統本身的類比速度。
如果為 為true,則使用分數差異量 delta 計算,將具有更平滑的粒子顯示效果。
Vector2 gravity = Vector2(0, 980) 🔗
套用於每個粒子的重力。
Each particle's hue will vary along this Curve. Should be a unit Curve.
float hue_variation_max = 0.0 🔗
套用於每個粒子的最大初始色相變化。會改變粒子顏色的色相。
float hue_variation_min = 0.0 🔗
hue_variation_max 的對應最小值。
float initial_velocity_max = 0.0 🔗
每個粒子的最大初始速度大小。方向來自 direction 和 spread。
float initial_velocity_min = 0.0 🔗
initial_velocity_max 的對應最小值。
每個粒子存在的時間。
float lifetime_randomness = 0.0 🔗
粒子壽命隨機率。
Each particle's linear acceleration will vary along this Curve. Should be a unit Curve.
float linear_accel_max = 0.0 🔗
在運動方向上套用於每個粒子的最大線性加速度。
float linear_accel_min = 0.0 🔗
linear_accel_max 的對應最小值。
如果為 true,粒子使用父節點的座標空間(稱為局部座標)。這將導致粒子在移動或旋轉時,沿著 CPUParticles2D 節點(及其父節點)移動和旋轉。如果為 false,則粒子使用全域座標;當移動或旋轉時,它們不會沿著 CPUParticles2D 節點(及其父節點)移動或旋轉。
如果為 true,則只發生一個發射週期。如果在某個週期內設定為 true,則發射將在該週期結束時停止。
Each particle's orbital velocity will vary along this Curve. Should be a unit Curve.
float orbit_velocity_max = 0.0 🔗
套用於每個粒子的最大軌道速度。使粒子圍繞原點旋轉。以每秒圍繞原點的完整旋轉數指定。
float orbit_velocity_min = 0.0 🔗
orbit_velocity_max 的對應最小值。
bool particle_flag_align_y = false 🔗
void set_particle_flag(particle_flag: ParticleFlags, enable: bool)
bool get_particle_flag(particle_flag: ParticleFlags) const
將粒子的 Y 軸與其速度方向對齊。
粒子系統啟動時就好像已經運作了這麼多秒一樣。
Each particle's radial acceleration will vary along this Curve. Should be a unit Curve.
float radial_accel_max = 0.0 🔗
套用於每個粒子的最大徑向加速度。使粒子加速遠離原點;或如果為負,則加速靠近原點。
float radial_accel_min = 0.0 🔗
radial_accel_max 的對應最小值。
發射壽命隨機率。
Each particle's scale will vary along this Curve. Should be a unit Curve.
float scale_amount_max = 1.0 🔗
套用於每個粒子的最大初始縮放。
float scale_amount_min = 1.0 🔗
scale_amount_max 的對應最小值。
Each particle's horizontal scale will vary along this Curve. Should be a unit Curve.
split_scale must be enabled.
Each particle's vertical scale will vary along this Curve. Should be a unit Curve.
split_scale must be enabled.
Sets the random seed used by the particle system. Only effective if use_fixed_seed is true.
粒子系統的運作速度的縮放率。0 值可用於暫停粒子。
如果為 true,縮放曲線將被拆分成 x 和 y 分量。見 scale_curve_x 和 scale_curve_y。
每個粒子的初始方向範圍,從 +spread 度到 -spread 度。
Curve tangential_accel_curve 🔗
Each particle's tangential acceleration will vary along this Curve. Should be a unit Curve.
float tangential_accel_max = 0.0 🔗
套用於每個粒子的最大切向加速度。切向加速度垂直於粒子的速度,從而使粒子產生渦旋運動。
float tangential_accel_min = 0.0 🔗
tangential_accel_max 的對應最小值。
粒子紋理。如果為 null,則粒子將為正方形。
If true, particles will use the same seed for every simulation using the seed defined in seed. This is useful for situations where the visual outcome should be consistent across replays, for example when using Movie Maker mode.
方法說明
void convert_from_particles(particles: Node) 🔗
設定該節點的屬性以配對給定的 GPUParticles2D 節點,該給定節點已分配了一個 ParticleProcessMaterial。
Curve get_param_curve(param: Parameter) const 🔗
float get_param_max(param: Parameter) const 🔗
返回給定參數的最大值範圍。
float get_param_min(param: Parameter) const 🔗
返回給定參數的最小值範圍。
bool get_particle_flag(particle_flag: ParticleFlags) const 🔗
Returns the enabled state of the given particle flag.
void request_particles_process(process_time: float, process_time_residual: float = 0.0) 🔗
Requests the particles to process for extra process time during a single frame.
process_time defines the time that the particles will process while emitting is on. process_time_residual defines the time that particles will process with emitting turned off for the simulation. When combined with speed_scale set to 0.0, this is useful to be able to seek a particle system timeline.
void restart(keep_seed: bool = false) 🔗
Restarts the particle emitter.
If keep_seed is true, the current random seed will be preserved. Useful for seeking and playback.
void set_param_curve(param: Parameter, curve: Curve) 🔗
Sets the Curve of the parameter specified by Parameter. Should be a unit Curve.
void set_param_max(param: Parameter, value: float) 🔗
設定給定參數的最大值。
void set_param_min(param: Parameter, value: float) 🔗
設定給定參數的最小值。
void set_particle_flag(particle_flag: ParticleFlags, enable: bool) 🔗
Enables or disables the given particle flag.