CPUParticles2D
A CPU-based 2D particle emitter.
CPUParticles2D.swift:19class CPUParticles2D
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.
This object emits the following signals:
Superclasses
class Node2D
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
Type members
Instance members
var amount: Int32
Number of particles emitted in one emission cycle.
var angleCurve: Curve?
Each particle’s rotation will be animated along this
Curve
.var angleMax: Double
Maximum initial rotation applied to each particle, in degrees.
var angleMin: Double
Minimum equivalent of
angleMax
.var angularVelocityCurve: Curve?
Each particle’s angular velocity will vary along this
Curve
.var angularVelocityMax: Double
Maximum initial angular velocity (rotation speed) applied to each particle in degrees per second.
var angularVelocityMin: Double
Minimum equivalent of
angularVelocityMax
.var animOffsetCurve: Curve?
Each particle’s animation offset will vary along this
Curve
.var animOffsetMax: Double
Maximum animation offset that corresponds to frame index in the texture.
0
is the first frame,1
is the last one. SeeparticlesAnimation
.var animOffsetMin: Double
Minimum equivalent of
animOffsetMax
.var animSpeedCurve: Curve?
Each particle’s animation speed will vary along this
Curve
.var animSpeedMax: Double
Maximum particle animation speed. Animation speed of
1
means that the particles will make full0
to1
offset cycle during lifetime,2
means2
cycles etc.var animSpeedMin: Double
Minimum equivalent of
animSpeedMax
.var color: Color
Each particle’s initial color. If
texture
is defined, it will be multiplied by this color.var colorInitialRamp: Gradient?
Each particle’s initial color will vary along this
GradientTexture1D
(multiplied withcolor
).var colorRamp: Gradient?
Each particle’s color will vary along this
Gradient
(multiplied withcolor
).var dampingCurve: Curve?
Damping will vary along this
Curve
.var dampingMax: Double
The maximum rate at which particles lose velocity. For example value of
100
means that the particle will go from100
velocity to0
in1
second.var dampingMin: Double
Minimum equivalent of
dampingMax
.var direction: Vector2
Unit vector specifying the particles’ emission direction.
var drawOrder: CPUParticles2D.DrawOrder
Particle draw order. Uses
DrawOrder
values.var emissionColors: PackedColorArray
Sets the
Color
s to modulate particles by when using .points or .directedPoints.var emissionNormals: PackedVector2Array
Sets the direction the particles will be emitted in when using .directedPoints.
var emissionPoints: PackedVector2Array
Sets the initial positions to spawn particles when using .points or .directedPoints.
var emissionRectExtents: Vector2
The rectangle’s extents if
emissionShape
is set to .rectangle.var emissionShape: CPUParticles2D.EmissionShape
Particles will be emitted inside this region. See
EmissionShape
for possible values.var emissionSphereRadius: Double
The sphere’s radius if
emissionShape
is set to .sphere.var emitting: Bool
If
true
, particles are being emitted.emitting
can be used to start and stop particles from emitting. However, ifoneShot
istrue
settingemitting
totrue
will not restart the emission cycle until after all active particles finish processing. You can use the [signal finished] signal to be notified once all active particles finish processing.var explosiveness: Double
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 finished: SimpleSignal
Emitted when all active particles have finished processing. When
oneShot
is disabled, particles will process continuously, so this is never emitted.var fixedFps: Int32
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 fractDelta: Bool
If
true
, results in fractional delta calculation which has a smoother particles display effect.var gravity: Vector2
Gravity applied to every particle.
var hueVariationCurve: Curve?
Each particle’s hue will vary along this
Curve
.var hueVariationMax: Double
Maximum initial hue variation applied to each particle. It will shift the particle color’s hue.
var hueVariationMin: Double
Minimum equivalent of
hueVariationMax
.var initialVelocityMax: Double
Maximum initial velocity magnitude for each particle. Direction comes from
direction
andspread
.var initialVelocityMin: Double
Minimum equivalent of
initialVelocityMax
.var lifetime: Double
Amount of time each particle will exist.
var lifetimeRandomness: Double
Particle lifetime randomness ratio.
var linearAccelCurve: Curve?
Each particle’s linear acceleration will vary along this
Curve
.var linearAccelMax: Double
Maximum linear acceleration applied to each particle in the direction of motion.
var linearAccelMin: Double
Minimum equivalent of
linearAccelMax
.var localCoords: Bool
If
true
, particles use the parent node’s coordinate space (known as local coordinates). This will cause particles to move and rotate along theCPUParticles2D
node (and its parents) when it is moved or rotated. Iffalse
, particles use global coordinates; they will not move or rotate along theCPUParticles2D
node (and its parents) when it is moved or rotated.var oneShot: Bool
If
true
, only one emission cycle occurs. If settrue
during a cycle, emission will stop at the cycle’s end.var orbitVelocityCurve: Curve?
Each particle’s orbital velocity will vary along this
Curve
.var orbitVelocityMax: Double
Maximum orbital velocity applied to each particle. Makes the particles circle around origin. Specified in number of full rotations around origin per second.
var orbitVelocityMin: Double
Minimum equivalent of
orbitVelocityMax
.var particleFlagAlignY: Bool
Align Y axis of particle with the direction of its velocity.
var preprocess: Double
Particle system starts as if it had already run for this many seconds.
var radialAccelCurve: Curve?
Each particle’s radial acceleration will vary along this
Curve
.var radialAccelMax: Double
Maximum radial acceleration applied to each particle. Makes particle accelerate away from the origin or towards it if negative.
var radialAccelMin: Double
Minimum equivalent of
radialAccelMax
.var randomness: Double
Emission lifetime randomness ratio.
var scaleAmountCurve: Curve?
Each particle’s scale will vary along this
Curve
.var scaleAmountMax: Double
Maximum initial scale applied to each particle.
var scaleAmountMin: Double
Minimum equivalent of
scaleAmountMax
.var scaleCurveX: Curve?
Each particle’s horizontal scale will vary along this
Curve
.var scaleCurveY: Curve?
Each particle’s vertical scale will vary along this
Curve
.var speedScale: Double
Particle system’s running speed scaling ratio. A value of
0
can be used to pause the particles.var splitScale: Bool
If
true
, the scale curve will be split into x and y components. SeescaleCurveX
andscaleCurveY
.var spread: Double
Each particle’s initial direction range from
+spread
to-spread
degrees.var tangentialAccelCurve: Curve?
Each particle’s tangential acceleration will vary along this
Curve
.var tangentialAccelMax: Double
Maximum tangential acceleration applied to each particle. Tangential acceleration is perpendicular to the particle’s velocity giving the particles a swirling motion.
var tangentialAccelMin: Double
Minimum equivalent of
tangentialAccelMax
.var texture: Texture2D?
Particle texture. If
null
, particles will be squares.func convertFromParticles(Node?
) Sets this node’s properties to match a given
GPUParticles2D
node with an assignedParticleProcessMaterial
.func restart(
) Restarts the particle emitter.