tguerin / newton

An Easy To Use Particle Emitter
https://newton.7omtech.fr
MIT License
22 stars 7 forks source link

Add pause/resume #27

Open angelorodem opened 3 weeks ago

angelorodem commented 3 weeks ago

With this feature, integrators can pause the emission and wait the particles finish smoothly, and later resume if needed.

netlify[bot] commented 3 weeks ago

Deploy Preview for imaginative-palmier-d7ee2c canceled.

Name Link
Latest commit 8534d78e63465f568a48fe015deb7bf8ff17ce97
Latest deploy log https://app.netlify.com/sites/imaginative-palmier-d7ee2c/deploys/666e12e095110e0008a4e19d
angelorodem commented 3 weeks ago

Related to issue #26

angelorodem commented 3 weeks ago

Tested this code with

    var effect = Newton(
      key: newtonKey,
    );

    var rainEffect = RainEffect(
      particleConfiguration: ParticleConfiguration(
        shape: CircleShape(),
        size: const Size(15, 15),
        color: SingleParticleColor(color: COULUMB_BLUE),
      ),
      effectConfiguration: EffectConfiguration(
          particleCount: 0,
          minDuration: 3000,
          maxDuration: 7000,
          particlesPerEmit: 3,
          maxFadeInLimit: 5,
          minFadeInLimit: 4),
    );

    if (appState.getIsCharging()) {
      print("Started animation");
      if (newtonKey.currentState!.isEffectsListEmpty()) {
        newtonKey.currentState?.addEffect(rainEffect);
      } else {
        print("Effects not empty");
      }

      newtonKey.currentState?.resumeEffects();
    } else {
      print("Stopped animation");
      newtonKey.currentState?.pauseEffects();
    }