From 955d7da27613c84ab435b8c3dd91168b919d118e Mon Sep 17 00:00:00 2001 From: Cosmo Myzrail Gorynych Date: Thu, 12 Mar 2020 16:17:50 +1200 Subject: [PATCH] :bug: Fix tandem.frozen, replace tandem.paused with tandem.pause() and tandem.resume() --- app/data/ct.release/emitters.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/data/ct.release/emitters.js b/app/data/ct.release/emitters.js index 17b830655..29ea5ec05 100644 --- a/app/data/ct.release/emitters.js +++ b/app/data/ct.release/emitters.js @@ -28,7 +28,6 @@ * A class for displaying and managing a collection of particle emitters. * * @property {boolean} frozen If set to true, the tandem will stop updating its emitters - * @property {boolean} paused If set to true, the tandem will prevent spawning new particles * @property {Copy|DisplayObject} follow A copy to follow * @extends PIXI.Container */ @@ -110,7 +109,7 @@ class EmitterTandem extends PIXI.Container { this.destroy(); return; } - if (this.paused) { + if (this.frozen) { return; } const s = (this.isUi? PIXI.Ticker.shared.elapsedMS : PIXI.Ticker.shared.deltaMS) / 1000; @@ -148,6 +147,26 @@ class EmitterTandem extends PIXI.Container { } this.delayed = []; } + /** + * Stops spawning new particles, but continues simulation and allows to resume the effect later + * with `emitter.resume();` + * @returns {void} + */ + pause() { + for (const emt of this.emitters) { + emt.oldMaxParticles = emt.maxParticles; + emt.maxParticles = 0; + } + } + /** + * Resumes previously paused effect. + * @returns {void} + */ + resume() { + for (const emt of this.emitters) { + emt.maxParticles = emt.oldMaxParticles || emt.maxParticles; + } + } /** * Removes all the particles from the tandem, but continues spawning new ones. * @returns {void}