ParticleSystem class
A particle system uses a large number of sprites to draw complex effects such as explosions, smoke, rain, or fire. There are a number of properties that can be set to control the look of the particle system. Most of the properties have a base value and a variance, these values are used when creating each individual particle. For instance, by setting the life to 1.0 and the lifeVar to 0.5, each particle will get a life time in the range of 0.5 to 1.5.
Particles are created and added to the system at emissionRate, but the number of particles can never exceed the maxParticles limit.
Constructors
- ParticleSystem({required SpriteTexture texture, double life = 1.5, double lifeVar = 1.0, Offset posVar = Offset.zero, double startSize = 2.5, double startSizeVar = 0.5, double endSize = 0.0, double endSizeVar = 0.0, double startRotation = 0.0, double startRotationVar = 0.0, double endRotation = 0.0, double endRotationVar = 0.0, bool rotateToMovement = false, double direction = 0.0, double directionVar = 360.0, double speed = 100.0, double speedVar = 50.0, double radialAcceleration = 0.0, double radialAccelerationVar = 0.0, double tangentialAcceleration = 0.0, double tangentialAccelerationVar = 0.0, int maxParticles = 100, double emissionRate = 50.0, ColorSequence? colorSequence, int alphaVar = 0, int redVar = 0, int greenVar = 0, int blueVar = 0, BlendMode blendMode = BlendMode.plus, int? numParticlesToEmit = 0, bool autoRemoveOnFinish = true, Offset? gravity, String? data})
- Creates a new particle system with the given properties. The only required parameter is the texture, all other parameters are optional.
Properties
- alphaVar ↔ int
-
Alpha varience of the colorSequence property.
getter/setter pair
- autoRemoveOnFinish ↔ bool
-
If set to true, the particle system will be automatically removed as soon
as there are no more particles left to draw.
getter/setter pair
- blendMode ↔ BlendMode
-
The transfer mode used to draw the particle system. Default is
BlendMode.plus.
getter/setter pair
- blueVar ↔ int
-
Blue varience of the colorSequence property.
getter/setter pair
-
children
→ List<
Node> -
A list of the children of this node.
no setterinherited
- colorSequence ↔ ColorSequence?
-
The ColorSequence used to animate the color of each individual particle
over the duration of its life. When applied to a particle the sequence's
color stops modified in accordance with the alphaVar, redVar,
greenVar, and blueVar properties.
getter/setter pair
-
constraints
↔ List<
Constraint> ? -
A List of
Constraint
s that will be applied to the node. The constraints are applied after the update method has been called.getter/setter pairinherited - direction ↔ double
-
The direction in which each particle will be emitted in degrees.
getter/setter pair
- directionVar ↔ double
-
Variance of the direction property.
getter/setter pair
- emissionRate ↔ double
-
The rate at which particles are emitted, defined in particles per second.
getter/setter pair
- endRotation ↔ double
-
The end rotation of each individual particle.
getter/setter pair
- endRotationVar ↔ double
-
Variance of the endRotation property.
getter/setter pair
- endSize ↔ double
-
The end scale of each individual particle.
getter/setter pair
- endSizeVar ↔ double
-
Variance of the endSize property.
getter/setter pair
- gravity ↔ Offset?
-
The gravity vector of the particle system.
getter/setter pair
- greenVar ↔ int
-
Green varience of the colorSequence property.
getter/setter pair
- handleMultiplePointers ↔ bool
-
If set to true the node will receive multiple pointers, otherwise it will
only receive events the first pointer.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- insertionOffset ↔ Offset
-
Offset of where the particles are inserted, this is useful for doing
particle systems where the source of the particles move (e.g. smoke
trailing a rocket).
getter/setter pair
- inverseTransformMatrix → Matrix4
-
The inverse transform matrix used by this node.
no setterinherited
- life ↔ double
-
The time in seconds each particle will be alive.
getter/setter pair
- lifeVar ↔ double
-
Variance of the life property.
getter/setter pair
- maxParticles ↔ int
-
The maximum number of particles the system can display at a single time.
getter/setter pair
- motions → MotionController
-
The MotionController associated with this node.
no setterinherited
- numParticlesToEmit ↔ int?
-
Total number of particles to emit, if the value is set to 0 the system
will continue to emit particles for an indifinte period of time.
getter/setter pair
- opacity ↔ double
-
The over all opacity of the particle system. This value is multiplied by
the opacity of the individual particles.
getter/setter pair
- parent → Node?
-
The parent of this node, or null if it doesn't have a parent.
no setterinherited
- paused ↔ bool
-
Decides if the node and its children is currently paused.
getter/setter pairinherited
- position ↔ Offset
-
The position of this node relative to its parent.
getter/setter pairinherited
- posVar ↔ Offset
-
The variance of a particles initial position.
getter/setter pair
- radialAcceleration ↔ double
-
The radial acceleration of each induvidual particle.
getter/setter pair
- radialAccelerationVar ↔ double
-
Variance of the radialAcceleration property.
getter/setter pair
- redVar ↔ int
-
Red varience of the colorSequence property.
getter/setter pair
- rotateToMovement ↔ bool
-
If true, each particle will be rotated to the direction of the movement
of the particle. The calculated rotation will be added to the current
rotation as calculated by the startRotation and endRotation
properties.
getter/setter pair
- rotation ↔ double
-
The rotation of this node in degrees.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale ↔ double
-
The scale of this node relative its parent.
getter/setter pairinherited
- scaleX ↔ double
-
The horizontal scale of this node relative its parent.
getter/setter pairinherited
- scaleY ↔ double
-
The vertical scale of this node relative its parent.
getter/setter pairinherited
- skewX ↔ double
-
The skew along the x-axis of this node in degrees.
getter/setter pairinherited
- skewY ↔ double
-
The skew along the y-axis of this node in degrees.
getter/setter pairinherited
- speed ↔ double
-
The speed at which each particle will be emitted.
getter/setter pair
- speedVar ↔ double
-
Variance of the direction property.
getter/setter pair
- spriteBox → SpriteBox?
-
The SpriteBox this node is added to, or null if it's not currently
added to a SpriteBox.
no setterinherited
- startRotation ↔ double
-
The start rotation of each individual particle.
getter/setter pair
- startRotationVar ↔ double
-
Variance of the startRotation property.
getter/setter pair
- startSize ↔ double
-
The start scale of each individual particle.
getter/setter pair
- startSizeVar ↔ double
-
Variance of the startSize property.
getter/setter pair
- tangentialAcceleration ↔ double
-
The tangential acceleration of each individual particle.
getter/setter pair
- tangentialAccelerationVar ↔ double
-
Variance of the tangentialAcceleration property.
getter/setter pair
- texture ↔ SpriteTexture
-
The texture used to draw each individual sprite.
getter/setter pair
- transformMatrix → Matrix4
-
The transformMatrix describes the transformation from the node's parent.
no setterinherited
- userInteractionEnabled ↔ bool
-
The node will receive user interactions, such as pointer (touch or mouse)
events.
getter/setter pairinherited
- visible ↔ bool
-
The visibility of this node and its children.
getter/setter pairinherited
- zPosition ↔ double
-
The draw order of this node compared to its parent and its siblings.
getter/setter pairinherited
Methods
-
addChild(
Node child) → void -
Adds a child to this node.
inherited
-
applyConstraints(
double dt) → void -
Called to apply the constraints to the node. Normally, this method is
called automatically by the SpriteBox, but it can be called manually
if the constraints need to be applied immediately.
inherited
-
computeTransformMatrix(
) → Matrix4 -
Computes the transformation matrix of this node. This method can be
overriden if a custom matrix is required. There is usually no reason to
call this method directly.
inherited
-
convertPointFromNode(
Offset point, Node node) → Offset -
Converts a
point
from anothernode
s coordinate system into the local coordinate system of this node.inherited -
convertPointToBoxSpace(
Offset nodePoint) → Offset -
Converts a point from the local coordinate system of the node to the
coordinate system of the SpriteBox.
inherited
-
convertPointToNodeSpace(
Offset boxPoint) → Offset -
Converts a point from the coordinate system of the SpriteBox to the
local coordinate system of the node.
inherited
-
handleEvent(
SpriteBoxEvent event) → bool -
Handles an event, such as a pointer (touch or mouse) event.
inherited
-
handleKeyboardEvent(
KeyEvent event) → bool -
Handles a keyboard event.
inherited
-
invalidateTransformMatrix(
) → void -
Invalidates the current transform matrix. If the computeTransformMatrix
method is overidden, this method should be called whenever a property
changes that affects the matrix.
inherited
-
isPointInside(
Offset point) → bool -
Returns true if the
point
is inside the node, thepoint
is in the local coordinate system of the node.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paint(
Canvas canvas) → void -
Paints this node to the canvas.
override
-
removeAllChildren(
) → void -
Removes all children of this node.
inherited
-
removeChild(
Node child) → void -
Removes a child from this node.
inherited
-
removeFromParent(
) → void -
Removes this node from its parent node.
inherited
-
reset(
) → void - Resets the particle system and starts it from scratch.
-
spriteBoxPerformedLayout(
) → void -
Called whenever the SpriteBox is modified or resized, or if the device
is rotated.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
double dt) → void -
Called before a frame is drawn.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited