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.

This commit is contained in:
Richard Davey 2017-10-20 14:14:22 +01:00
parent 6180feea8e
commit 93665ff80a

View file

@ -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++)
{