ParticleSystem constructor
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.
Implementation
ParticleSystem({
required this.texture,
this.life = 1.5,
this.lifeVar = 1.0,
this.posVar = Offset.zero,
this.startSize = 2.5,
this.startSizeVar = 0.5,
this.endSize = 0.0,
this.endSizeVar = 0.0,
this.startRotation = 0.0,
this.startRotationVar = 0.0,
this.endRotation = 0.0,
this.endRotationVar = 0.0,
this.rotateToMovement = false,
this.direction = 0.0,
this.directionVar = 360.0,
this.speed = 100.0,
this.speedVar = 50.0,
this.radialAcceleration = 0.0,
this.radialAccelerationVar = 0.0,
this.tangentialAcceleration = 0.0,
this.tangentialAccelerationVar = 0.0,
this.maxParticles = 100,
this.emissionRate = 50.0,
this.colorSequence,
this.alphaVar = 0,
this.redVar = 0,
this.greenVar = 0,
this.blueVar = 0,
this.blendMode = BlendMode.plus,
this.numParticlesToEmit = 0,
this.autoRemoveOnFinish = true,
Offset? gravity,
String? data,
}) {
this.gravity = gravity;
_particles = <_Particle>[];
_emitCounter = 0.0;
// _elapsedTime = 0.0;
_gravity ??= Vector2.zero();
colorSequence ??= ColorSequence.fromStartAndEndColor(
start: const Color(0xffffffff),
end: const Color(0x00ffffff),
);
insertionOffset = Offset.zero;
if (data != null) {
deserializeParticleSystem(json.decode(data), particleSystem: this);
}
}