2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2018-02-12 16:01:20 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2017-10-17 03:19:29 +00:00
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var Components = require('../components');
|
|
|
|
var GameObject = require('../GameObject');
|
2017-10-25 15:05:48 +00:00
|
|
|
var GravityWell = require('./GravityWell');
|
2017-10-20 13:14:22 +00:00
|
|
|
var List = require('../../structs/List');
|
2017-10-17 03:19:29 +00:00
|
|
|
var ParticleEmitter = require('./ParticleEmitter');
|
|
|
|
var Render = require('./ParticleManagerRender');
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-02-07 15:27:21 +00:00
|
|
|
* @classdesc
|
2018-04-18 15:32:03 +00:00
|
|
|
* A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @class ParticleEmitterManager
|
2018-04-16 13:43:24 +00:00
|
|
|
* @extends Phaser.GameObjects.GameObject
|
2018-10-10 09:49:13 +00:00
|
|
|
* @memberof Phaser.GameObjects.Particles
|
2018-02-06 22:25:23 +00:00
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-07-25 20:13:38 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.Depth
|
2019-04-12 16:46:39 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.Mask
|
2018-07-25 20:13:38 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.Pipeline
|
2018-07-31 22:21:07 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.Transform
|
2018-07-25 20:13:38 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.Visible
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @param {Phaser.Scene} scene - The Scene to which this Emitter Manager belongs.
|
|
|
|
* @param {string} texture - The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager.
|
2018-06-20 06:28:02 +00:00
|
|
|
* @param {(string|integer)} [frame] - An optional frame from the Texture this Emitter Manager will use to render particles.
|
2019-02-13 12:35:12 +00:00
|
|
|
* @param {Phaser.GameObjects.Particles.Types.ParticleEmitterConfig|Phaser.GameObjects.Particles.Types.ParticleEmitterConfig[]} [emitters] - Configuration settings for one or more emitters to create.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2017-10-17 03:19:29 +00:00
|
|
|
var ParticleEmitterManager = new Class({
|
|
|
|
|
|
|
|
Extends: GameObject,
|
|
|
|
|
|
|
|
Mixins: [
|
2017-10-20 13:14:22 +00:00
|
|
|
Components.Depth,
|
2019-04-12 16:46:39 +00:00
|
|
|
Components.Mask,
|
2018-01-29 21:46:48 +00:00
|
|
|
Components.Pipeline,
|
2018-07-31 22:21:07 +00:00
|
|
|
Components.Transform,
|
2018-05-30 08:44:49 +00:00
|
|
|
Components.Visible,
|
2017-10-17 03:19:29 +00:00
|
|
|
Render
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-10-20 02:20:39 +00:00
|
|
|
// frame is optional and can contain the emitters array or object if skipped
|
2017-10-17 03:19:29 +00:00
|
|
|
function ParticleEmitterManager (scene, texture, frame, emitters)
|
|
|
|
{
|
|
|
|
GameObject.call(this, scene, 'ParticleEmitterManager');
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-06-20 06:28:02 +00:00
|
|
|
* The blend mode applied to all emitters and particles.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode
|
2018-04-18 15:32:03 +00:00
|
|
|
* @type {integer}
|
2018-02-06 22:25:23 +00:00
|
|
|
* @default -1
|
|
|
|
* @private
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-17 03:19:29 +00:00
|
|
|
this.blendMode = -1;
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement.
|
|
|
|
* Values larger than 1 are faster than normal.
|
|
|
|
* This is multiplied with any timeScale set on each individual emitter.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale
|
2018-06-20 06:28:02 +00:00
|
|
|
* @type {number}
|
2018-02-06 22:25:23 +00:00
|
|
|
* @default 1
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-17 20:32:45 +00:00
|
|
|
this.timeScale = 1;
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* The texture used to render this Emitter Manager's particles.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture
|
|
|
|
* @type {Phaser.Textures.Texture}
|
|
|
|
* @default null
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-18 14:18:42 +00:00
|
|
|
this.texture = null;
|
2018-02-06 22:25:23 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* The texture frame used to render this Emitter Manager's particles.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame
|
|
|
|
* @type {Phaser.Textures.Frame}
|
|
|
|
* @default null
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-18 14:18:42 +00:00
|
|
|
this.frame = null;
|
2018-02-06 22:25:23 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Names of this Emitter Manager's texture frames.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames
|
2018-05-22 14:55:36 +00:00
|
|
|
* @type {string[]}
|
2018-02-06 22:25:23 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-18 14:18:42 +00:00
|
|
|
this.frameNames = [];
|
|
|
|
|
2017-11-17 13:30:07 +00:00
|
|
|
// frame is optional and can contain the emitters array or object if skipped
|
|
|
|
if (frame !== null && (typeof frame === 'object' || Array.isArray(frame)))
|
2017-10-20 02:20:39 +00:00
|
|
|
{
|
|
|
|
emitters = frame;
|
|
|
|
frame = null;
|
|
|
|
}
|
|
|
|
|
2017-10-17 03:19:29 +00:00
|
|
|
this.setTexture(texture, frame);
|
2018-02-06 22:25:23 +00:00
|
|
|
|
2018-09-05 10:19:02 +00:00
|
|
|
this.initPipeline();
|
2017-10-17 03:19:29 +00:00
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
|
|
|
* A list of Emitters being managed by this Emitter Manager.
|
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters
|
2018-05-22 14:55:36 +00:00
|
|
|
* @type {Phaser.Structs.List.<Phaser.GameObjects.Particles.ParticleEmitter>}
|
2018-02-06 22:25:23 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-20 13:14:22 +00:00
|
|
|
this.emitters = new List(this);
|
2017-10-17 03:19:29 +00:00
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
|
|
|
* A list of Gravity Wells being managed by this Emitter Manager.
|
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells
|
2018-03-23 15:54:12 +00:00
|
|
|
* @type {Phaser.Structs.List.<Phaser.GameObjects.Particles.GravityWell>}
|
2018-02-06 22:25:23 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-25 15:05:48 +00:00
|
|
|
this.wells = new List(this);
|
|
|
|
|
2017-11-17 13:30:07 +00:00
|
|
|
if (emitters)
|
2017-10-17 03:19:29 +00:00
|
|
|
{
|
|
|
|
// An array of emitter configs?
|
|
|
|
if (!Array.isArray(emitters))
|
|
|
|
{
|
|
|
|
emitters = [ emitters ];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < emitters.length; i++)
|
|
|
|
{
|
|
|
|
this.createEmitter(emitters[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Sets the texture and frame this Emitter Manager will use to render with.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* Textures are referenced by their string-based keys, as stored in the Texture Manager.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the texture to be used, as stored in the Texture Manager.
|
2018-03-20 14:56:31 +00:00
|
|
|
* @param {(string|integer)} [frame] - The name or index of the frame within the Texture.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2017-10-18 14:18:42 +00:00
|
|
|
setTexture: function (key, frame)
|
|
|
|
{
|
|
|
|
this.texture = this.scene.sys.textures.get(key);
|
|
|
|
|
|
|
|
return this.setFrame(frame);
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Sets the frame this Emitter Manager will use to render with.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* The Frame has to belong to the current Texture being used.
|
|
|
|
*
|
|
|
|
* It can be either a string or an index.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-20 14:56:31 +00:00
|
|
|
* @param {(string|integer)} [frame] - The name or index of the frame within the Texture.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2017-10-18 14:18:42 +00:00
|
|
|
setFrame: function (frame)
|
|
|
|
{
|
|
|
|
this.frame = this.texture.get(frame);
|
|
|
|
|
2018-09-27 13:15:58 +00:00
|
|
|
var frames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex);
|
|
|
|
|
|
|
|
var names = [];
|
|
|
|
|
|
|
|
frames.forEach(function (sourceFrame)
|
|
|
|
{
|
|
|
|
names.push(sourceFrame.name);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.frameNames = names;
|
2017-10-18 14:18:42 +00:00
|
|
|
|
2017-10-19 23:54:47 +00:00
|
|
|
this.defaultFrame = this.frame;
|
|
|
|
|
2017-10-18 14:18:42 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Assigns texture frames to an emitter.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @param {(Phaser.Textures.Frame|Phaser.Textures.Frame[])} frames - The texture frames.
|
|
|
|
* @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The particle emitter to modify.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2017-10-18 14:18:42 +00:00
|
|
|
setEmitterFrames: function (frames, emitter)
|
|
|
|
{
|
|
|
|
if (!Array.isArray(frames))
|
|
|
|
{
|
|
|
|
frames = [ frames ];
|
|
|
|
}
|
|
|
|
|
|
|
|
var out = emitter.frames;
|
|
|
|
|
|
|
|
out.length = 0;
|
|
|
|
|
|
|
|
for (var i = 0; i < frames.length; i++)
|
|
|
|
{
|
|
|
|
var frame = frames[i];
|
|
|
|
|
|
|
|
if (this.frameNames.indexOf(frame) !== -1)
|
|
|
|
{
|
|
|
|
out.push(this.texture.get(frame));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-19 23:54:47 +00:00
|
|
|
if (out.length > 0)
|
|
|
|
{
|
|
|
|
emitter.defaultFrame = out[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
emitter.defaultFrame = this.defaultFrame;
|
|
|
|
}
|
|
|
|
|
2017-10-18 14:18:42 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Adds an existing Particle Emitter to this Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager.
|
|
|
|
*
|
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager.
|
|
|
|
*/
|
2017-10-17 03:19:29 +00:00
|
|
|
addEmitter: function (emitter)
|
|
|
|
{
|
2017-10-20 13:14:22 +00:00
|
|
|
return this.emitters.add(emitter);
|
2017-10-17 03:19:29 +00:00
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2019-02-13 12:35:12 +00:00
|
|
|
* @param {Phaser.GameObjects.Particles.Types.ParticleEmitterConfig} config - Configuration settings for the Particle Emitter to create.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created.
|
|
|
|
*/
|
2017-10-17 03:19:29 +00:00
|
|
|
createEmitter: function (config)
|
|
|
|
{
|
|
|
|
return this.addEmitter(new ParticleEmitter(this, config));
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Adds an existing Gravity Well object to this Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager.
|
|
|
|
*
|
|
|
|
* @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager.
|
|
|
|
*/
|
2017-10-25 15:05:48 +00:00
|
|
|
addGravityWell: function (well)
|
|
|
|
{
|
|
|
|
return this.wells.add(well);
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2019-02-13 12:35:12 +00:00
|
|
|
* @param {Phaser.GameObjects.Particles.Types.GravityWellConfig} config - Configuration settings for the Gravity Well to create.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created.
|
|
|
|
*/
|
2017-10-25 15:05:48 +00:00
|
|
|
createGravityWell: function (config)
|
|
|
|
{
|
|
|
|
return this.addGravityWell(new GravityWell(config));
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Emits particles from each active emitter.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}.
|
2018-06-20 06:28:02 +00:00
|
|
|
* @param {number} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location.
|
|
|
|
* @param {number} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2018-01-12 17:09:09 +00:00
|
|
|
emitParticle: function (count, x, y)
|
2017-10-20 13:14:22 +00:00
|
|
|
{
|
|
|
|
var emitters = this.emitters.list;
|
|
|
|
|
|
|
|
for (var i = 0; i < emitters.length; i++)
|
|
|
|
{
|
|
|
|
var emitter = emitters[i];
|
|
|
|
|
|
|
|
if (emitter.active)
|
|
|
|
{
|
2018-01-12 17:09:09 +00:00
|
|
|
emitter.emitParticle(count, x, y);
|
2017-10-20 13:14:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Emits particles from each active emitter.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-06-20 06:28:02 +00:00
|
|
|
* @param {number} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location.
|
|
|
|
* @param {number} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location.
|
2018-04-18 15:32:03 +00:00
|
|
|
* @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2018-01-12 17:09:09 +00:00
|
|
|
emitParticleAt: function (x, y, count)
|
2017-10-20 13:14:22 +00:00
|
|
|
{
|
2018-01-12 17:09:09 +00:00
|
|
|
return this.emitParticle(count, x, y);
|
2017-10-20 13:14:22 +00:00
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
|
|
|
* Pauses this Emitter Manager.
|
|
|
|
*
|
|
|
|
* This has the effect of pausing all emitters, and all particles of those emitters, currently under its control.
|
|
|
|
*
|
|
|
|
* The particles will still render, but they will not have any of their logic updated.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2017-10-17 03:19:29 +00:00
|
|
|
pause: function ()
|
|
|
|
{
|
|
|
|
this.active = false;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
|
|
|
* Resumes this Emitter Manager, should it have been previously paused.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2017-10-17 03:19:29 +00:00
|
|
|
resume: function ()
|
|
|
|
{
|
|
|
|
this.active = true;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Gets all active particle processors (gravity wells).
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-18 15:32:03 +00:00
|
|
|
* @return {Phaser.GameObjects.Particles.GravityWell[]} - The active gravity wells.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2017-10-25 15:05:48 +00:00
|
|
|
getProcessors: function ()
|
|
|
|
{
|
|
|
|
return this.wells.getAll('active', true);
|
|
|
|
},
|
|
|
|
|
2018-02-06 22:25:23 +00:00
|
|
|
/**
|
2018-04-18 15:32:03 +00:00
|
|
|
* Updates all active emitters.
|
2018-02-06 22:25:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-18 13:43:37 +00:00
|
|
|
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
|
2018-06-20 06:28:02 +00:00
|
|
|
* @param {number} delta - The delta time, in ms, elapsed since the last frame.
|
2018-02-06 22:25:23 +00:00
|
|
|
*/
|
2017-10-17 03:19:29 +00:00
|
|
|
preUpdate: function (time, delta)
|
|
|
|
{
|
2017-10-17 20:32:45 +00:00
|
|
|
// Scale the delta
|
|
|
|
delta *= this.timeScale;
|
|
|
|
|
2017-10-20 13:14:22 +00:00
|
|
|
var emitters = this.emitters.list;
|
2017-10-17 03:19:29 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < emitters.length; i++)
|
|
|
|
{
|
|
|
|
var emitter = emitters[i];
|
|
|
|
|
|
|
|
if (emitter.active)
|
|
|
|
{
|
|
|
|
emitter.preUpdate(time, delta);
|
|
|
|
}
|
|
|
|
}
|
2018-05-31 23:03:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A NOOP method so you can pass an EmitterManager to a Container.
|
|
|
|
* Calling this method will do nothing. It is intentionally empty.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#setAlpha
|
|
|
|
* @private
|
|
|
|
* @since 3.10.0
|
|
|
|
*/
|
|
|
|
setAlpha: function ()
|
|
|
|
{
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A NOOP method so you can pass an EmitterManager to a Container.
|
|
|
|
* Calling this method will do nothing. It is intentionally empty.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#setScrollFactor
|
|
|
|
* @private
|
|
|
|
* @since 3.10.0
|
|
|
|
*/
|
|
|
|
setScrollFactor: function ()
|
|
|
|
{
|
2018-10-05 15:31:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A NOOP method so you can pass an EmitterManager to a Container.
|
|
|
|
* Calling this method will do nothing. It is intentionally empty.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Particles.ParticleEmitterManager#setBlendMode
|
|
|
|
* @private
|
|
|
|
* @since 3.15.0
|
|
|
|
*/
|
|
|
|
setBlendMode: function ()
|
|
|
|
{
|
2017-10-17 03:19:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = ParticleEmitterManager;
|