ParticleSystem constructor

ParticleSystem({
  1. required SpriteTexture texture,
  2. double life = 1.5,
  3. double lifeVar = 1.0,
  4. Offset posVar = Offset.zero,
  5. double startSize = 2.5,
  6. double startSizeVar = 0.5,
  7. double endSize = 0.0,
  8. double endSizeVar = 0.0,
  9. double startRotation = 0.0,
  10. double startRotationVar = 0.0,
  11. double endRotation = 0.0,
  12. double endRotationVar = 0.0,
  13. bool rotateToMovement = false,
  14. double direction = 0.0,
  15. double directionVar = 360.0,
  16. double speed = 100.0,
  17. double speedVar = 50.0,
  18. double radialAcceleration = 0.0,
  19. double radialAccelerationVar = 0.0,
  20. double tangentialAcceleration = 0.0,
  21. double tangentialAccelerationVar = 0.0,
  22. int maxParticles = 100,
  23. double emissionRate = 50.0,
  24. ColorSequence? colorSequence,
  25. int alphaVar = 0,
  26. int redVar = 0,
  27. int greenVar = 0,
  28. int blueVar = 0,
  29. BlendMode blendMode = BlendMode.plus,
  30. int? numParticlesToEmit = 0,
  31. bool autoRemoveOnFinish = true,
  32. Offset? gravity,
  33. 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);
  }
}