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(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 transferMode: BlendMode.plus, int numParticlesToEmit: 0, bool autoRemoveOnFinish: true, Offset gravity })
- 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.read / write - autoRemoveOnFinish ↔ bool
-
If set to true, the particle system will be automatically removed as soon
as there are no more particles left to draw.
read / write
- blueVar ↔ int
-
Blue varience of the
colorSequence
property.read / write - colorSequence ↔ ColorSequence
-
The
ColorSequence
used to animate the color of each individual particle over the duration of itslife
. When applied to a particle the sequence's color stops modified in accordance with thealphaVar
,redVar
,greenVar
, andblueVar
properties.read / write - direction ↔ double
-
The direction in which each particle will be emitted in degrees.
read / write
- directionVar ↔ double
-
Variance of the
direction
property.read / write - emissionRate ↔ double
-
The rate at which particles are emitted, defined in particles per second.
read / write
- endRotation ↔ double
-
The end rotation of each individual particle.
read / write
- endRotationVar ↔ double
-
Variance of the
endRotation
property.read / write - endSize ↔ double
-
The end scale of each individual particle.
read / write
- endSizeVar ↔ double
-
Variance of the
endSize
property.read / write - gravity ↔ Offset
-
The gravity vector of the particle system.
read / write
- greenVar ↔ int
-
Green varience of the
colorSequence
property.read / write - life ↔ double
-
The time in seconds each particle will be alive.
read / write
- lifeVar ↔ double
-
Variance of the
life
property.read / write - maxParticles ↔ int
-
The maximum number of particles the system can display at a single time.
read / write
- 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.
read / write
- opacity ↔ double
-
The over all opacity of the particle system. This value is multiplied by
the opacity of the individual particles.
read / write
- posVar ↔ Offset
-
The variance of a particles initial position.
read / write
- radialAcceleration ↔ double
-
The radial acceleration of each induvidual particle.
read / write
- radialAccelerationVar ↔ double
-
Variance of the
radialAcceleration
property.read / write - redVar ↔ int
-
Red varience of the
colorSequence
property.read / write - 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
andendRotation
properties.read / write - speed ↔ double
-
The speed at which each particle will be emitted.
read / write
- speedVar ↔ double
-
Variance of the
direction
property.read / write - startRotation ↔ double
-
The start rotation of each individual particle.
read / write
- startRotationVar ↔ double
-
Variance of the
startRotation
property.read / write - startSize ↔ double
-
The start scale of each individual particle.
read / write
- startSizeVar ↔ double
-
Variance of the
startSize
property.read / write - tangentialAcceleration ↔ double
-
The tangential acceleration of each individual particle.
read / write
- tangentialAccelerationVar ↔ double
-
Variance of the
tangentialAcceleration
property.read / write - texture ↔ SpriteTexture
-
The texture used to draw each individual sprite.
read / write
- transferMode ↔ BlendMode
-
The transfer mode used to draw the particle system. Default is
BlendMode.plus
.read / write - actions → ActionController
-
The ActionController associated with this node. [...]
read-only, inherited
- children → List<Node>
-
A list of the children of this node. [...]
read-only, inherited
- constraints ↔ List<Constraint>
-
A List of Constraints that will be applied to the node.
The constraints are applied after the update method has been called.
read / write, inherited
- handleMultiplePointers ↔ bool
-
If set to true the node will receive multiple pointers, otherwise it will only receive events the first pointer. [...]
read / write, inherited
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- inverseTransformMatrix → Matrix4
-
The inverse transform matrix used by this node.
read-only, inherited
- parent → Node
-
The parent of this node, or null if it doesn't have a parent. [...]
read-only, inherited
- paused ↔ bool
-
Decides if the node and its children is currently paused. [...]
read / write, inherited
- position ↔ Offset
-
The position of this node relative to its parent. [...]
read / write, inherited
- rotation ↔ double
-
The rotation of this node in degrees. [...]
read / write, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- scale ↔ double
-
The scale of this node relative its parent. [...]
read / write, inherited
- scaleX ↔ double
-
The horizontal scale of this node relative its parent. [...]
read / write, inherited
- scaleY ↔ double
-
The vertical scale of this node relative its parent. [...]
read / write, inherited
- skewX ↔ double
-
The skew along the x-axis of this node in degrees. [...]
read / write, inherited
- skewY ↔ double
-
The skew along the y-axis of this node in degrees. [...]
read / write, inherited
- spriteBox → SpriteBox
-
The SpriteBox this node is added to, or null if it's not currently added to a SpriteBox. [...]
read-only, inherited
- transformMatrix → Matrix4
-
The transformMatrix describes the transformation from the node's parent. [...]
read-only, inherited
- userInteractionEnabled ↔ bool
-
The node will receive user interactions, such as pointer (touch or mouse) events. [...]
read / write, inherited
- visible ↔ bool
-
The visibility of this node and its children.
read / write, inherited
- zPosition ↔ double
-
The draw order of this node compared to its parent and its siblings. [...]
read / write, inherited
Methods
-
paint(
Canvas canvas) → void - Paints this node to the canvas. [...]
-
update(
double dt) → void - Called before a frame is drawn. [...]
-
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
-
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 non-existent method or property is accessed. [...]
inherited
-
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
-
spriteBoxPerformedLayout(
) → void -
Called whenever the SpriteBox is modified or resized, or if the device is rotated. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
other) → bool -
The equality operator. [...]
inherited