ParticleEmitter constructor
ParticleEmitter({
- int maxParticles = 1024,
- double rate = 0,
- List<
EmitterBurst> bursts = const [], - double? duration,
- bool loop = false,
- ParticleRange lifespan = (1, 1),
- EmitterShape shape = const PointEmitterShape(),
- ParticleRange speed = (0, 0),
- double direction = 0,
- double spread = tau,
- Vector2? gravity,
- double drag = 0,
- ParticleRange size = (8, 8),
- ParticleRange rotation = (0, 0),
- ParticleRange spin = (0, 0),
- bool rotateToVelocity = false,
- ParticleCurve? scaleOverLife,
- ParticleCurve? opacityOverLife,
- ColorRamp? colorOverLife,
Creates an emitter preset.
Emission is continuous through rate (particles per second) and/or
discrete through bursts. An emitter with only bursts finishes after
the last burst has fired; an emitter with a positive rate keeps
emitting until duration has passed, or forever when duration is
null. With loop enabled the emission timeline restarts after
duration, which must then be set.
Implementation
ParticleEmitter({
this.maxParticles = 1024,
this.rate = 0,
this.bursts = const [],
this.duration,
this.loop = false,
this.lifespan = (1, 1),
this.shape = const PointEmitterShape(),
this.speed = (0, 0),
this.direction = 0,
this.spread = tau,
Vector2? gravity,
this.drag = 0,
this.size = (8, 8),
this.rotation = (0, 0),
this.spin = (0, 0),
this.rotateToVelocity = false,
this.scaleOverLife,
this.opacityOverLife,
this.colorOverLife,
}) : assert(maxParticles > 0, 'maxParticles must be positive'),
assert(rate >= 0, 'rate must not be negative'),
assert(spread >= 0, 'spread must not be negative'),
assert(drag >= 0, 'drag must not be negative'),
assert(duration == null || duration > 0, 'duration must be positive'),
assert(
!loop || duration != null,
'loop requires duration to be set',
),
gravity = gravity ?? Vector2.zero();