setLifespan method

void setLifespan(
  1. double lifespan
)
inherited

A control method allowing a parent of this Particle to pass down it's lifespan.

Allows to only specify desired lifespan once, at the very top of the Particle tree which then will be propagated down using this method.

See SingleChildParticle or ComposedParticle for details.

Implementation

void setLifespan(double lifespan) {
  // TODO(wolfenrain): Maybe make it into a setter/getter?
  _lifespan = lifespan;
  _timer?.stop();
  _timer = Timer(lifespan, onTick: () => _shouldBeRemoved = true)..start();
}