Class CPUParticles2D
A CPU-based 2D particle emitter.
- Inheritance
-
CPUParticles2D
Remarks
CPU-based 2D particle node used to create a variety of particle systems and effects.
See also GPUParticles2D, which provides the same functionality with hardware acceleration, but may not run on older devices.
See Also
Properties
amount
Number of particles emitted in one emission cycle.
var amount : int = 8
Property Value
Remarks
angle_curve
var angle_curve : Curve
Property Value
Remarks
angle_max
Maximum initial rotation applied to each particle, in degrees.
var angle_max : float = 0.0
Property Value
Remarks
angle_min
Minimum equivalent of angle_max.
var angle_min : float = 0.0
Property Value
Remarks
angular_velocity_curve
var angular_velocity_curve : Curve
Property Value
Remarks
angular_velocity_max
Maximum initial angular velocity (rotation speed) applied to each particle in degrees per second.
var angular_velocity_max : float = 0.0
Property Value
Remarks
angular_velocity_min
Minimum equivalent of angular_velocity_max.
var angular_velocity_min : float = 0.0
Property Value
Remarks
anim_offset_curve
var anim_offset_curve : Curve
Property Value
Remarks
anim_offset_max
Maximum animation offset that corresponds to frame index in the texture. 0
is the first frame, 1
is the last one. See particles_animation.
var anim_offset_max : float = 0.0
Property Value
Remarks
anim_offset_min
Minimum equivalent of anim_offset_max.
var anim_offset_min : float = 0.0
Property Value
Remarks
anim_speed_curve
var anim_speed_curve : Curve
Property Value
Remarks
anim_speed_max
Maximum particle animation speed. Animation speed of 1
means that the particles will make full 0
to 1
offset cycle during lifetime, 2
means 2
cycles etc.
With animation speed greater than 1
, remember to enable particles_anim_loop property if you want the animation to repeat.
var anim_speed_max : float = 0.0
Property Value
Remarks
anim_speed_min
Minimum equivalent of anim_speed_max.
var anim_speed_min : float = 0.0
Property Value
Remarks
color
Each particle's initial color. If texture is defined, it will be multiplied by this color.
var color : Color = Color(1, 1, 1, 1)
Property Value
Remarks
color_initial_ramp
var color_initial_ramp : Gradient
Property Value
Remarks
color_ramp
var color_ramp : Gradient
Property Value
Remarks
damping_curve
var damping_curve : Curve
Property Value
Remarks
damping_max
The maximum rate at which particles lose velocity. For example value of 100
means that the particle will go from 100
velocity to 0
in 1
second.
var damping_max : float = 0.0
Property Value
Remarks
damping_min
Minimum equivalent of damping_max.
var damping_min : float = 0.0
Property Value
Remarks
direction
Unit vector specifying the particles' emission direction.
var direction : Vector2 = Vector2(1, 0)
Property Value
Remarks
draw_order
Particle draw order. Uses DrawOrder values.
var draw_order : int = 0
Property Value
Remarks
emission_colors
Sets the Colors to modulate particles by when using CPUParticles2D.EMISSION_SHAPE_POINTS or CPUParticles2D.EMISSION_SHAPE_DIRECTED_POINTS.
var emission_colors : PackedColorArray
Property Value
Remarks
- void set_emission_colors(PackedColorArray value)
- PackedColorArray get_emission_colors
emission_normals
Sets the direction the particles will be emitted in when using CPUParticles2D.EMISSION_SHAPE_DIRECTED_POINTS.
var emission_normals : PackedVector2Array
Property Value
Remarks
- void set_emission_normals(PackedVector2Array value)
- PackedVector2Array get_emission_normals
emission_points
Sets the initial positions to spawn particles when using CPUParticles2D.EMISSION_SHAPE_POINTS or CPUParticles2D.EMISSION_SHAPE_DIRECTED_POINTS.
var emission_points : PackedVector2Array
Property Value
Remarks
- void set_emission_points(PackedVector2Array value)
- PackedVector2Array get_emission_points
emission_rect_extents
The rectangle's extents if emission_shape is set to CPUParticles2D.EMISSION_SHAPE_RECTANGLE.
var emission_rect_extents : Vector2
Property Value
Remarks
emission_shape
Particles will be emitted inside this region. See EmissionShape for possible values.
var emission_shape : int = 0
Property Value
Remarks
emission_sphere_radius
The sphere's radius if emission_shape is set to CPUParticles2D.EMISSION_SHAPE_SPHERE.
var emission_sphere_radius : float
Property Value
Remarks
emitting
If true
, particles are being emitted. emitting can be used to start and stop particles from emitting. However, if one_shot is true
setting emitting to true
will not restart the emission cycle until after all active particles finish processing. You can use the finished signal to be notified once all active particles finish processing.
var emitting : bool = true
Property Value
Remarks
explosiveness
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.
var explosiveness : float = 0.0
Property Value
Remarks
fixed_fps
The particle system's frame rate is fixed to a value. For example, 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.
var fixed_fps : int = 0
Property Value
Remarks
fract_delta
If true
, results in fractional delta calculation which has a smoother particles display effect.
var fract_delta : bool = true
Property Value
Remarks
gravity
Gravity applied to every particle.
var gravity : Vector2 = Vector2(0, 980)
Property Value
Remarks
hue_variation_curve
var hue_variation_curve : Curve
Property Value
Remarks
hue_variation_max
Maximum initial hue variation applied to each particle. It will shift the particle color's hue.
var hue_variation_max : float = 0.0
Property Value
Remarks
hue_variation_min
Minimum equivalent of hue_variation_max.
var hue_variation_min : float = 0.0
Property Value
Remarks
initial_velocity_max
var initial_velocity_max : float = 0.0
Property Value
Remarks
initial_velocity_min
Minimum equivalent of initial_velocity_max.
var initial_velocity_min : float = 0.0
Property Value
Remarks
lifetime
Amount of time each particle will exist.
var lifetime : float = 1.0
Property Value
Remarks
lifetime_randomness
Particle lifetime randomness ratio.
var lifetime_randomness : float = 0.0
Property Value
Remarks
linear_accel_curve
var linear_accel_curve : Curve
Property Value
Remarks
linear_accel_max
Maximum linear acceleration applied to each particle in the direction of motion.
var linear_accel_max : float = 0.0
Property Value
Remarks
linear_accel_min
Minimum equivalent of linear_accel_max.
var linear_accel_min : float = 0.0
Property Value
Remarks
local_coords
If true
, particles use the parent node's coordinate space (known as local coordinates). This will cause particles to move and rotate along the CPUParticles2D node (and its parents) when it is moved or rotated. If false
, particles use global coordinates; they will not move or rotate along the CPUParticles2D node (and its parents) when it is moved or rotated.
var local_coords : bool = false
Property Value
Remarks
one_shot
If true
, only one emission cycle occurs. If set true
during a cycle, emission will stop at the cycle's end.
var one_shot : bool = false
Property Value
Remarks
orbit_velocity_curve
var orbit_velocity_curve : Curve
Property Value
Remarks
orbit_velocity_max
Maximum orbital velocity applied to each particle. Makes the particles circle around origin. Specified in number of full rotations around origin per second.
var orbit_velocity_max : float = 0.0
Property Value
Remarks
orbit_velocity_min
Minimum equivalent of orbit_velocity_max.
var orbit_velocity_min : float = 0.0
Property Value
Remarks
particle_flag_align_y
Align Y axis of particle with the direction of its velocity.
var particle_flag_align_y : bool = false
Property Value
Remarks
preprocess
Particle system starts as if it had already run for this many seconds.
var preprocess : float = 0.0
Property Value
Remarks
radial_accel_curve
var radial_accel_curve : Curve
Property Value
Remarks
radial_accel_max
Maximum radial acceleration applied to each particle. Makes particle accelerate away from the origin or towards it if negative.
var radial_accel_max : float = 0.0
Property Value
Remarks
radial_accel_min
Minimum equivalent of radial_accel_max.
var radial_accel_min : float = 0.0
Property Value
Remarks
randomness
Emission lifetime randomness ratio.
var randomness : float = 0.0
Property Value
Remarks
scale_amount_curve
var scale_amount_curve : Curve
Property Value
Remarks
scale_amount_max
Maximum initial scale applied to each particle.
var scale_amount_max : float = 1.0
Property Value
Remarks
scale_amount_min
Minimum equivalent of scale_amount_max.
var scale_amount_min : float = 1.0
Property Value
Remarks
scale_curve_x
Each particle's horizontal scale will vary along this Curve. Should be a unit Curve.
split_scale must be enabled.
var scale_curve_x : Curve
Property Value
Remarks
scale_curve_y
Each particle's vertical scale will vary along this Curve. Should be a unit Curve.
split_scale must be enabled.
var scale_curve_y : Curve
Property Value
Remarks
seed
Sets the random seed used by the particle system. Only effective if use_fixed_seed is true
.
var seed : int = 0
Property Value
Remarks
speed_scale
Particle system's running speed scaling ratio. A value of 0
can be used to pause the particles.
var speed_scale : float = 1.0
Property Value
Remarks
split_scale
If true
, the scale curve will be split into x and y components. See scale_curve_x and scale_curve_y.
var split_scale : bool = false
Property Value
Remarks
spread
Each particle's initial direction range from +spread
to -spread
degrees.
var spread : float = 45.0
Property Value
Remarks
tangential_accel_curve
var tangential_accel_curve : Curve
Property Value
Remarks
tangential_accel_max
Maximum tangential acceleration applied to each particle. Tangential acceleration is perpendicular to the particle's velocity giving the particles a swirling motion.
var tangential_accel_max : float = 0.0
Property Value
Remarks
tangential_accel_min
Minimum equivalent of tangential_accel_max.
var tangential_accel_min : float = 0.0
Property Value
Remarks
texture
Particle texture. If null
, particles will be squares.
var texture : Texture2D
Property Value
Remarks
use_fixed_seed
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.
var use_fixed_seed : bool = false
Property Value
Remarks
Methods
convert_from_particles(Node)
Sets this node's properties to match a given GPUParticles2D node with an assigned ParticleProcessMaterial.
void convert_from_particles(Node particles)
Parameters
particles
Node
get_param_curve(int)
Qualifiers: const
Returns the Curve of the parameter specified by Parameter.
Curve get_param_curve(int param)
Parameters
param
int
get_param_max(int)
Qualifiers: const
Returns the maximum value range for the given parameter.
float get_param_max(int param)
Parameters
param
int
get_param_min(int)
Qualifiers: const
Returns the minimum value range for the given parameter.
float get_param_min(int param)
Parameters
param
int
get_particle_flag(int)
Qualifiers: const
Returns the enabled state of the given particle flag (see ParticleFlags for options).
bool get_particle_flag(int particle_flag)
Parameters
particle_flag
int
request_particles_process(float)
Requests the particles to process for extra process time during a single frame.
Useful for particle playback, if used in combination with use_fixed_seed or by calling CPUParticles2D.restart with parameter keep_seed
set to true
.
void request_particles_process(float process_time)
Parameters
process_time
float
restart(bool)
Restarts the particle emitter.
If keep_seed
is true
, the current random seed will be preserved. Useful for seeking and playback.
void restart(bool keep_seed)
Parameters
keep_seed
bool
set_param_curve(int, Curve)
void set_param_curve(int param, Curve curve)
Parameters
set_param_max(int, float)
Sets the maximum value for the given parameter.
void set_param_max(int param, float value)
Parameters
set_param_min(int, float)
Sets the minimum value for the given parameter.
void set_param_min(int param, float value)
Parameters
set_particle_flag(int, bool)
Enables or disables the given flag (see ParticleFlags for options).
void set_particle_flag(int particle_flag, bool enable)
Parameters
Events
finished
Emitted when all active particles have finished processing. When one_shot is disabled, particles will process continuously, so this is never emitted.
signal finished