From 93665ff80a2f161716fadbf9d8e26e5f73de5ae3 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 20 Oct 2017 14:14:22 +0100 Subject: [PATCH] Emitter Manager now uses a list to allow for emitter sequencing. Added missing depth component. Added ability to emit across all emitters from a given coordinate. --- .../particles/ParticleEmitterManager.js | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/v3/src/gameobjects/particles/ParticleEmitterManager.js b/v3/src/gameobjects/particles/ParticleEmitterManager.js index ead58ee98..2b79caba0 100644 --- a/v3/src/gameobjects/particles/ParticleEmitterManager.js +++ b/v3/src/gameobjects/particles/ParticleEmitterManager.js @@ -1,6 +1,7 @@ var Class = require('../../utils/Class'); var Components = require('../components'); var GameObject = require('../GameObject'); +var List = require('../../structs/List'); var ParticleEmitter = require('./ParticleEmitter'); var Render = require('./ParticleManagerRender'); @@ -9,6 +10,7 @@ var ParticleEmitterManager = new Class({ Extends: GameObject, Mixins: [ + Components.Depth, Components.RenderTarget, Components.Visible, Render @@ -38,7 +40,7 @@ var ParticleEmitterManager = new Class({ this.setTexture(texture, frame); - this.emitters = []; + this.emitters = new List(this); if (emitters !== undefined) { @@ -108,9 +110,7 @@ var ParticleEmitterManager = new Class({ addEmitter: function (emitter) { - this.emitters.push(emitter); - - return emitter; + return this.emitters.add(emitter); }, createEmitter: function (config) @@ -118,6 +118,28 @@ var ParticleEmitterManager = new Class({ return this.addEmitter(new ParticleEmitter(this, config)); }, + emit: function (count, x, y) + { + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.emit(count, x, y); + } + } + + return this; + }, + + emitAt: function (x, y, count) + { + return this.emit(count, x, y); + }, + pause: function () { this.active = false; @@ -137,7 +159,7 @@ var ParticleEmitterManager = new Class({ // Scale the delta delta *= this.timeScale; - var emitters = this.emitters; + var emitters = this.emitters.list; for (var i = 0; i < emitters.length; i++) {