Skip to content

Commit

Permalink
🐛 Fix tandem.frozen, replace tandem.paused with tandem.pause() and ta…
Browse files Browse the repository at this point in the history
…ndem.resume()
  • Loading branch information
CosmoMyzrailGorynych committed Mar 12, 2020
1 parent 8d3f4a3 commit 955d7da
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions app/data/ct.release/emitters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 955d7da

Please sign in to comment.