2013-10-01 12:54:29 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2014-02-05 05:54:25 +00:00
|
|
|
* @copyright 2014 Photon Storm Ltd.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
/**
|
|
|
|
* Phaser - ArcadeEmitter
|
|
|
|
*
|
2013-10-01 12:54:29 +00:00
|
|
|
* @class Phaser.Particles.Arcade.Emitter
|
|
|
|
* @classdesc Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
|
2013-09-10 00:26:50 +00:00
|
|
|
* continuous effects like rain and fire. All it really does is launch Particle objects out
|
|
|
|
* at set intervals, and fixes their positions and velocities accorindgly.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @constructor
|
2013-10-02 19:18:24 +00:00
|
|
|
* @extends Phaser.Group
|
2013-10-01 12:54:29 +00:00
|
|
|
* @param {Phaser.Game} game - Current game instance.
|
2013-10-02 19:18:24 +00:00
|
|
|
* @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from.
|
|
|
|
* @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from.
|
|
|
|
* @param {number} [maxParticles=50] - The total number of particles in this emitter..
|
2013-09-10 00:26:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* @property {number} maxParticles - The total number of particles in this emitter..
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-11-25 04:40:04 +00:00
|
|
|
this.maxParticles = maxParticles || 50;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2013-11-25 04:40:04 +00:00
|
|
|
Phaser.Group.call(this, game);
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2014-04-10 00:48:55 +00:00
|
|
|
* @property {string} name - A handy string name for this emitter. Can be set to anything.
|
2013-11-25 04:40:04 +00:00
|
|
|
*/
|
2013-09-10 10:09:25 +00:00
|
|
|
this.name = 'emitter' + this.game.particles.ID++;
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} type - Internal Phaser Type value.
|
|
|
|
* @protected
|
2013-11-25 04:40:04 +00:00
|
|
|
*/
|
2013-09-12 20:54:41 +00:00
|
|
|
this.type = Phaser.EMITTER;
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
/**
|
2013-11-25 04:40:04 +00:00
|
|
|
* @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box.
|
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this.width = 1;
|
|
|
|
|
|
|
|
/**
|
2013-10-01 12:54:29 +00:00
|
|
|
* @property {number} height - The height of the emitter. Particles can be randomly generated from anywhere within this box.
|
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this.height = 1;
|
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {Phaser.Point} minParticleSpeed - The minimum possible velocity of a particle.
|
|
|
|
* @default
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this.minParticleSpeed = new Phaser.Point(-100, -100);
|
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {Phaser.Point} maxParticleSpeed - The maximum possible velocity of a particle.
|
|
|
|
* @default
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this.maxParticleSpeed = new Phaser.Point(100, 100);
|
|
|
|
|
2013-09-10 10:18:50 +00:00
|
|
|
/**
|
2014-04-10 04:18:06 +00:00
|
|
|
* @property {number} minParticleScale - The minimum possible scale of a particle. This is applied to the X and Y axis. If you need to control each axis see minParticleScaleX.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 10:18:50 +00:00
|
|
|
this.minParticleScale = 1;
|
|
|
|
|
|
|
|
/**
|
2014-04-10 04:18:06 +00:00
|
|
|
* @property {number} maxParticleScale - The maximum possible scale of a particle. This is applied to the X and Y axis. If you need to control each axis see maxParticleScaleX.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 10:18:50 +00:00
|
|
|
this.maxParticleScale = 1;
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
/**
|
|
|
|
* @property {array} scaleData - An array of the calculated scale easing data applied to particles with scaleRates > 0.
|
|
|
|
*/
|
|
|
|
this.scaleData = null;
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} minRotation - The minimum possible angular velocity of a particle.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this.minRotation = -360;
|
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} maxRotation - The maximum possible angular velocity of a particle.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this.maxRotation = 360;
|
|
|
|
|
2014-04-09 13:29:23 +00:00
|
|
|
/**
|
|
|
|
* @property {number} minParticleAlpha - The minimum possible alpha value of a particle.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.minParticleAlpha = 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {number} maxParticleAlpha - The maximum possible alpha value of a particle.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.maxParticleAlpha = 1;
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
/**
|
|
|
|
* @property {array} alphaData - An array of the calculated alpha easing data applied to particles with alphaRates > 0.
|
|
|
|
*/
|
|
|
|
this.alphaData = null;
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} gravity - Sets the `body.gravity.y` of each particle sprite to this value on launch.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2014-01-27 06:29:26 +00:00
|
|
|
this.gravity = 100;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2014-04-09 13:29:23 +00:00
|
|
|
* @property {any} particleClass - For emitting your own particle class types. They must extend Phaser.Particle.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2014-04-09 13:29:23 +00:00
|
|
|
this.particleClass = Phaser.Particle;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2014-03-20 03:48:54 +00:00
|
|
|
* @property {Phaser.Point} particleDrag - The X and Y drag component of particles launched from the emitter.
|
2013-11-25 04:40:04 +00:00
|
|
|
*/
|
2014-03-20 03:48:54 +00:00
|
|
|
this.particleDrag = new Phaser.Point();
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2013-09-16 00:08:06 +00:00
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} angularDrag - The angular drag component of particles launched from the emitter if they are rotating.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-16 00:08:06 +00:00
|
|
|
this.angularDrag = 0;
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {boolean} frequency - How often a particle is emitted in ms (if emitter is started with Explode === false).
|
2013-11-25 04:40:04 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this.frequency = 100;
|
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} lifespan - How long each particle lives once it is emitted in ms. Default is 2 seconds. Set lifespan to 'zero' for particles to live forever.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this.lifespan = 2000;
|
|
|
|
|
|
|
|
/**
|
2014-04-09 13:29:23 +00:00
|
|
|
* @property {Phaser.Point} bounce - How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.
|
2013-11-25 04:40:04 +00:00
|
|
|
*/
|
2013-09-16 00:08:06 +00:00
|
|
|
this.bounce = new Phaser.Point();
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2014-04-09 13:29:23 +00:00
|
|
|
/**
|
|
|
|
* @property {boolean} on - Determines whether the emitter is currently emitting particles. It is totally safe to directly toggle this.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.on = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {Phaser.Point} particleAnchor - When a particle is created its anchor will be set to match this Point object (defaults to x/y: 0.5 to aid in rotation)
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.particleAnchor = new Phaser.Point(0.5, 0.5);
|
|
|
|
|
|
|
|
/**
|
2014-04-09 15:12:25 +00:00
|
|
|
* @property {number} blendMode - The blendMode as set on the particle when emitted from the Emitter. Defaults to NORMAL. Needs browser capable of supporting canvas blend-modes (most not available in WebGL)
|
2014-04-09 13:29:23 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2014-04-09 15:12:25 +00:00
|
|
|
this.blendMode = Phaser.blendModes.NORMAL;
|
2014-04-09 13:29:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The point the particles are emitted from.
|
|
|
|
* Emitter.x and Emitter.y control the containers location, which updates all current particles
|
|
|
|
* Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.
|
|
|
|
* @property {number} emitX
|
|
|
|
*/
|
|
|
|
this.emitX = x;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The point the particles are emitted from.
|
|
|
|
* Emitter.x and Emitter.y control the containers location, which updates all current particles
|
|
|
|
* Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.
|
|
|
|
* @property {number} emitY
|
|
|
|
*/
|
|
|
|
this.emitY = y;
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
/**
|
|
|
|
* @property {boolean} autoScale - When a new Particle is emitted this controls if it will automatically scale in size. Use Emitter.setScale to configure.
|
|
|
|
*/
|
|
|
|
this.autoScale = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {boolean} autoAlpha - When a new Particle is emitted this controls if it will automatically change alpha. Use Emitter.setAlpha to configure.
|
|
|
|
*/
|
|
|
|
this.autoAlpha = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {boolean} particleBringToTop - If this is `true` then when the Particle is emitted it will be bought to the top of the Emitters display list.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.particleBringToTop = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {boolean} particleSendToBack - If this is `true` then when the Particle is emitted it will be sent to the back of the Emitters display list.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.particleSendToBack = false;
|
|
|
|
|
2014-04-10 04:18:06 +00:00
|
|
|
/**
|
|
|
|
* @property {Phaser.Point} _minParticleScale - Internal particle scale var.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._minParticleScale = new Phaser.Point(1, 1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {Phaser.Point} _maxParticleScale - Internal particle scale var.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._maxParticleScale = new Phaser.Point(1, 1);
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} _quantity - Internal helper for deciding how many particles to launch.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this._quantity = 0;
|
|
|
|
|
2013-11-25 04:40:04 +00:00
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} _timer - Internal helper for deciding when to launch particles or kill them.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this._timer = 0;
|
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {number} _counter - Internal counter for figuring out how many particles to launch.
|
2013-11-25 04:40:04 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this._counter = 0;
|
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* @property {boolean} _explode - Internal helper for the style of particle emission (all at once, or one at a time).
|
2013-11-25 04:40:04 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
this._explode = true;
|
|
|
|
|
2014-03-11 02:49:55 +00:00
|
|
|
/**
|
|
|
|
* @property {any} _frames - Internal helper for the particle frame.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._frames = null;
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Phaser.Particles.Arcade.Emitter.prototype = Object.create(Phaser.Group.prototype);
|
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.constructor = Phaser.Particles.Arcade.Emitter;
|
|
|
|
|
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* Called automatically by the game loop, decides when to launch particles and when to "die".
|
|
|
|
* @method Phaser.Particles.Arcade.Emitter#update
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.update = function () {
|
|
|
|
|
|
|
|
if (this.on)
|
|
|
|
{
|
|
|
|
if (this._explode)
|
|
|
|
{
|
2013-11-25 04:40:04 +00:00
|
|
|
this._counter = 0;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2013-11-25 04:40:04 +00:00
|
|
|
this.emitParticle();
|
|
|
|
this._counter++;
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
while (this._counter < this._quantity);
|
|
|
|
|
|
|
|
this.on = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-25 04:40:04 +00:00
|
|
|
if (this.game.time.now >= this._timer)
|
|
|
|
{
|
2013-09-10 00:26:50 +00:00
|
|
|
this.emitParticle();
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-11-25 04:40:04 +00:00
|
|
|
this._counter++;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
if (this._quantity > 0)
|
|
|
|
{
|
2013-11-25 04:40:04 +00:00
|
|
|
if (this._counter >= this._quantity)
|
|
|
|
{
|
|
|
|
this.on = false;
|
|
|
|
}
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._timer = this.game.time.now + this.frequency;
|
2013-11-25 04:40:04 +00:00
|
|
|
}
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-10 03:19:43 +00:00
|
|
|
var i = this.children.length;
|
|
|
|
|
|
|
|
while (i--)
|
|
|
|
{
|
|
|
|
if (this.children[i].exists)
|
|
|
|
{
|
|
|
|
this.children[i].update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2014-04-09 13:29:23 +00:00
|
|
|
* This function generates a new set of particles for use by this emitter.
|
|
|
|
* The particles are stored internally waiting to be emitted via Emitter.start.
|
2013-10-02 19:18:24 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Particles.Arcade.Emitter#makeParticles
|
2014-01-27 06:29:26 +00:00
|
|
|
* @param {array|string} keys - A string or an array of strings that the particle sprites will use as their texture. If an array one is picked at random.
|
2014-04-09 13:29:23 +00:00
|
|
|
* @param {array|number} [frames=0] - A frame number, or array of frames that the sprite will use. If an array one is picked at random.
|
|
|
|
* @param {number} [quantity] - The number of particles to generate. If not given it will use the value of Emitter.maxParticles.
|
|
|
|
* @param {boolean} [collide=false] - If you want the particles to be able to collide with other Arcade Physics bodies then set this to true.
|
2014-01-27 06:29:26 +00:00
|
|
|
* @param {boolean} [collideWorldBounds=false] - A particle can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.
|
|
|
|
* @return {Phaser.Particles.Arcade.Emitter} This Emitter instance.
|
2013-10-02 19:18:24 +00:00
|
|
|
*/
|
2013-09-16 00:08:06 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) {
|
2013-09-10 10:09:25 +00:00
|
|
|
|
2014-01-27 06:29:26 +00:00
|
|
|
if (typeof frames === 'undefined') { frames = 0; }
|
|
|
|
if (typeof quantity === 'undefined') { quantity = this.maxParticles; }
|
|
|
|
if (typeof collide === 'undefined') { collide = false; }
|
|
|
|
if (typeof collideWorldBounds === 'undefined') { collideWorldBounds = false; }
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
var particle;
|
|
|
|
var i = 0;
|
2013-09-10 10:09:25 +00:00
|
|
|
var rndKey = keys;
|
2014-01-27 17:08:12 +00:00
|
|
|
var rndFrame = frames;
|
2014-03-11 02:49:55 +00:00
|
|
|
this._frames = frames;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
while (i < quantity)
|
|
|
|
{
|
2014-03-20 03:48:54 +00:00
|
|
|
if (typeof keys === 'object')
|
2013-09-10 00:26:50 +00:00
|
|
|
{
|
2014-03-20 03:48:54 +00:00
|
|
|
rndKey = this.game.rnd.pick(keys);
|
|
|
|
}
|
2013-09-10 10:09:25 +00:00
|
|
|
|
2014-03-20 03:48:54 +00:00
|
|
|
if (typeof frames === 'object')
|
|
|
|
{
|
|
|
|
rndFrame = this.game.rnd.pick(frames);
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
2014-03-20 03:48:54 +00:00
|
|
|
|
|
|
|
particle = new this.particleClass(this.game, 0, 0, rndKey, rndFrame);
|
|
|
|
|
2014-03-23 12:07:55 +00:00
|
|
|
this.game.physics.arcade.enable(particle, false);
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2014-01-27 06:29:26 +00:00
|
|
|
if (collide)
|
2013-09-10 00:26:50 +00:00
|
|
|
{
|
2014-01-24 03:53:11 +00:00
|
|
|
particle.body.checkCollision.any = true;
|
|
|
|
particle.body.checkCollision.none = false;
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-24 03:53:11 +00:00
|
|
|
particle.body.checkCollision.none = true;
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
|
2013-09-16 00:08:06 +00:00
|
|
|
particle.body.collideWorldBounds = collideWorldBounds;
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
particle.exists = false;
|
|
|
|
particle.visible = false;
|
2014-04-09 13:29:23 +00:00
|
|
|
particle.anchor.copyFrom(this.particleAnchor);
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
this.add(particle);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2014-03-20 03:48:54 +00:00
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* Call this function to turn off all the particles and the emitter.
|
2014-04-09 13:29:23 +00:00
|
|
|
*
|
2014-01-27 06:29:26 +00:00
|
|
|
* @method Phaser.Particles.Arcade.Emitter#kill
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.kill = function () {
|
|
|
|
|
|
|
|
this.on = false;
|
|
|
|
this.alive = false;
|
|
|
|
this.exists = false;
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
|
2014-04-09 13:29:23 +00:00
|
|
|
*
|
2014-01-27 06:29:26 +00:00
|
|
|
* @method Phaser.Particles.Arcade.Emitter#revive
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.revive = function () {
|
|
|
|
|
|
|
|
this.alive = true;
|
|
|
|
this.exists = true;
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* Call this function to start emitting particles.
|
|
|
|
* @method Phaser.Particles.Arcade.Emitter#start
|
2014-04-09 13:29:23 +00:00
|
|
|
* @param {boolean} [explode=true] - Whether the particles should all burst out at once (true) or at the frequency given (false).
|
|
|
|
* @param {number} [lifespan=0] - How long each particle lives once emitted in ms. 0 = forever.
|
2014-04-10 04:18:06 +00:00
|
|
|
* @param {number} [frequency=250] - Ignored if Explode is set to true. Frequency is how often to emit 1 particle. Value given in ms.
|
2014-01-27 06:29:26 +00:00
|
|
|
* @param {number} [quantity=0] - How many particles to launch. 0 = "all of the particles".
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity) {
|
|
|
|
|
2014-01-27 06:29:26 +00:00
|
|
|
if (typeof explode === 'undefined') { explode = true; }
|
|
|
|
if (typeof lifespan === 'undefined') { lifespan = 0; }
|
2014-04-09 13:29:23 +00:00
|
|
|
if (typeof frequency === 'undefined' || frequency === null) { frequency = 250; }
|
2014-01-27 06:29:26 +00:00
|
|
|
if (typeof quantity === 'undefined') { quantity = 0; }
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
this.revive();
|
|
|
|
|
|
|
|
this.visible = true;
|
|
|
|
this.on = true;
|
|
|
|
|
|
|
|
this._explode = explode;
|
|
|
|
this.lifespan = lifespan;
|
|
|
|
this.frequency = frequency;
|
2013-09-16 00:08:06 +00:00
|
|
|
|
|
|
|
if (explode)
|
|
|
|
{
|
|
|
|
this._quantity = quantity;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this._quantity += quantity;
|
|
|
|
}
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
this._counter = 0;
|
|
|
|
this._timer = this.game.time.now + frequency;
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2014-04-09 13:29:23 +00:00
|
|
|
* This function can be used both internally and externally to emit the next particle in the queue.
|
|
|
|
*
|
2014-01-27 06:29:26 +00:00
|
|
|
* @method Phaser.Particles.Arcade.Emitter#emitParticle
|
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
|
|
|
|
|
|
|
|
var particle = this.getFirstExists(false);
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
if (particle === null)
|
2013-09-10 00:26:50 +00:00
|
|
|
{
|
2013-11-25 04:40:04 +00:00
|
|
|
return;
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.width > 1 || this.height > 1)
|
|
|
|
{
|
2013-11-25 04:40:04 +00:00
|
|
|
particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom));
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-25 04:40:04 +00:00
|
|
|
particle.reset(this.emitX, this.emitY);
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
particle.angle = 0;
|
2013-09-10 00:26:50 +00:00
|
|
|
particle.lifespan = this.lifespan;
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
if (this.particleBringToTop)
|
2013-09-10 00:26:50 +00:00
|
|
|
{
|
2014-04-10 00:36:05 +00:00
|
|
|
this.bringToTop(particle);
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
2014-04-10 00:36:05 +00:00
|
|
|
else if (this.particleSendToBack)
|
2013-09-10 00:26:50 +00:00
|
|
|
{
|
2014-04-10 00:36:05 +00:00
|
|
|
this.sendToBack(particle);
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
if (this.autoScale)
|
2013-09-10 00:26:50 +00:00
|
|
|
{
|
2014-04-10 00:36:05 +00:00
|
|
|
particle.setScaleData(this.scaleData);
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
2014-04-19 23:47:50 +00:00
|
|
|
else if (this.minParticleScale !== 1 || this.maxParticleScale !== 1)
|
2013-09-10 00:26:50 +00:00
|
|
|
{
|
2014-04-10 00:36:05 +00:00
|
|
|
particle.scale.set(this.game.rnd.realInRange(this.minParticleScale, this.maxParticleScale));
|
2013-09-10 00:26:50 +00:00
|
|
|
}
|
2014-04-10 04:18:06 +00:00
|
|
|
else if ((this._minParticleScale.x !== this._maxParticleScale.x) || (this._minParticleScale.y !== this._maxParticleScale.y))
|
|
|
|
{
|
|
|
|
particle.scale.set(this.game.rnd.realInRange(this._minParticleScale.x, this._maxParticleScale.x), this.game.rnd.realInRange(this._minParticleScale.y, this._maxParticleScale.y));
|
|
|
|
}
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
if (Array.isArray(this._frames === 'object'))
|
2014-03-11 02:49:55 +00:00
|
|
|
{
|
|
|
|
particle.frame = this.game.rnd.pick(this._frames);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
particle.frame = this._frames;
|
|
|
|
}
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
if (this.autoAlpha)
|
|
|
|
{
|
|
|
|
particle.setAlphaData(this.alphaData);
|
|
|
|
}
|
|
|
|
else
|
2014-04-09 13:29:23 +00:00
|
|
|
{
|
|
|
|
particle.alpha = this.game.rnd.realInRange(this.minParticleAlpha, this.maxParticleAlpha);
|
|
|
|
}
|
|
|
|
|
2014-04-09 15:12:25 +00:00
|
|
|
particle.blendMode = this.blendMode;
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
particle.body.updateBounds();
|
|
|
|
|
|
|
|
particle.body.bounce.setTo(this.bounce.x, this.bounce.y);
|
|
|
|
|
|
|
|
particle.body.velocity.x = this.game.rnd.integerInRange(this.minParticleSpeed.x, this.maxParticleSpeed.x);
|
|
|
|
particle.body.velocity.y = this.game.rnd.integerInRange(this.minParticleSpeed.y, this.maxParticleSpeed.y);
|
|
|
|
particle.body.angularVelocity = this.game.rnd.integerInRange(this.minRotation, this.maxRotation);
|
|
|
|
|
2014-03-20 03:48:54 +00:00
|
|
|
particle.body.gravity.y = this.gravity;
|
2014-04-10 00:36:05 +00:00
|
|
|
|
2014-03-20 03:48:54 +00:00
|
|
|
particle.body.drag.x = this.particleDrag.x;
|
|
|
|
particle.body.drag.y = this.particleDrag.y;
|
2014-04-10 00:36:05 +00:00
|
|
|
|
2013-09-16 00:08:06 +00:00
|
|
|
particle.body.angularDrag = this.angularDrag;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
particle.onEmit();
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* A more compact way of setting the width and height of the emitter.
|
|
|
|
* @method Phaser.Particles.Arcade.Emitter#setSize
|
2014-01-27 06:29:26 +00:00
|
|
|
* @param {number} width - The desired width of the emitter (particles are spawned randomly within these dimensions).
|
|
|
|
* @param {number} height - The desired height of the emitter.
|
2013-10-02 19:18:24 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) {
|
|
|
|
|
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* A more compact way of setting the X velocity range of the emitter.
|
|
|
|
* @method Phaser.Particles.Arcade.Emitter#setXSpeed
|
2014-01-27 06:29:26 +00:00
|
|
|
* @param {number} [min=0] - The minimum value for this range.
|
|
|
|
* @param {number} [max=0] - The maximum value for this range.
|
2013-10-02 19:18:24 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) {
|
|
|
|
|
2013-11-25 04:40:04 +00:00
|
|
|
min = min || 0;
|
|
|
|
max = max || 0;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
this.minParticleSpeed.x = min;
|
|
|
|
this.maxParticleSpeed.x = max;
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* A more compact way of setting the Y velocity range of the emitter.
|
|
|
|
* @method Phaser.Particles.Arcade.Emitter#setYSpeed
|
2014-01-27 06:29:26 +00:00
|
|
|
* @param {number} [min=0] - The minimum value for this range.
|
|
|
|
* @param {number} [max=0] - The maximum value for this range.
|
2013-10-02 19:18:24 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) {
|
|
|
|
|
2013-11-25 04:40:04 +00:00
|
|
|
min = min || 0;
|
|
|
|
max = max || 0;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
this.minParticleSpeed.y = min;
|
|
|
|
this.maxParticleSpeed.y = max;
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
/**
|
2014-04-09 15:12:25 +00:00
|
|
|
* A more compact way of setting the angular velocity constraints of the particles.
|
|
|
|
*
|
2013-10-02 19:18:24 +00:00
|
|
|
* @method Phaser.Particles.Arcade.Emitter#setRotation
|
2014-01-27 06:29:26 +00:00
|
|
|
* @param {number} [min=0] - The minimum value for this range.
|
|
|
|
* @param {number} [max=0] - The maximum value for this range.
|
2013-10-02 19:18:24 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) {
|
|
|
|
|
2013-11-25 04:40:04 +00:00
|
|
|
min = min || 0;
|
|
|
|
max = max || 0;
|
2013-09-10 00:26:50 +00:00
|
|
|
|
|
|
|
this.minRotation = min;
|
|
|
|
this.maxRotation = max;
|
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2014-04-09 13:29:23 +00:00
|
|
|
/**
|
2014-04-09 15:12:25 +00:00
|
|
|
* A more compact way of setting the alpha constraints of the particles.
|
2014-04-10 00:36:05 +00:00
|
|
|
* The rate parameter, if set to a value above zero, lets you set the speed at which the Particle change in alpha from min to max.
|
|
|
|
* If rate is zero, which is the default, the particle won't change alpha - instead it will pick a random alpha between min and max on emit.
|
2014-04-09 13:29:23 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Particles.Arcade.Emitter#setAlpha
|
|
|
|
* @param {number} [min=1] - The minimum value for this range.
|
|
|
|
* @param {number} [max=1] - The maximum value for this range.
|
2014-04-10 00:36:05 +00:00
|
|
|
* @param {number} [rate=0] - The rate (in ms) at which the particles will change in alpha from min to max, or set to zero to pick a random alpha between the two.
|
|
|
|
* @param {number} [ease=Phaser.Easing.Linear.None] - If you've set a rate > 0 this is the easing formula applied between the min and max values.
|
|
|
|
* @param {boolean} [yoyo=false] - If you've set a rate > 0 you can set if the ease will yoyo or not (i.e. ease back to its original values)
|
2014-04-09 13:29:23 +00:00
|
|
|
*/
|
2014-04-10 00:36:05 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.setAlpha = function (min, max, rate, ease, yoyo) {
|
2014-04-09 13:29:23 +00:00
|
|
|
|
|
|
|
if (typeof min === 'undefined') { min = 1; }
|
|
|
|
if (typeof max === 'undefined') { max = 1; }
|
2014-04-10 00:36:05 +00:00
|
|
|
if (typeof rate === 'undefined') { rate = 0; }
|
|
|
|
if (typeof ease === 'undefined') { ease = Phaser.Easing.Linear.None; }
|
|
|
|
if (typeof yoyo === 'undefined') { yoyo = false; }
|
2014-04-09 13:29:23 +00:00
|
|
|
|
|
|
|
this.minParticleAlpha = min;
|
|
|
|
this.maxParticleAlpha = max;
|
2014-04-10 00:36:05 +00:00
|
|
|
this.autoAlpha = false;
|
|
|
|
|
2014-04-10 03:19:43 +00:00
|
|
|
if (rate > 0 && min !== max)
|
2014-04-10 00:36:05 +00:00
|
|
|
{
|
|
|
|
var tweenData = { v: min };
|
|
|
|
var tween = this.game.make.tween(tweenData).to( { v: max }, rate, ease);
|
|
|
|
tween.yoyo(yoyo);
|
|
|
|
|
|
|
|
this.alphaData = tween.generateData(60);
|
|
|
|
|
|
|
|
// Inverse it so we don't have to do array length look-ups in Particle update loops
|
|
|
|
this.alphaData.reverse();
|
|
|
|
this.autoAlpha = true;
|
|
|
|
}
|
2014-04-09 13:29:23 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-04-09 15:12:25 +00:00
|
|
|
/**
|
|
|
|
* A more compact way of setting the scale constraints of the particles.
|
2014-04-10 04:18:06 +00:00
|
|
|
* The rate parameter, if set to a value above zero, lets you set the speed and ease which the Particle uses to change in scale from min to max across both axis.
|
|
|
|
* If rate is zero, which is the default, the particle won't change scale during update, instead it will pick a random scale between min and max on emit.
|
2014-04-09 15:12:25 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Particles.Arcade.Emitter#setScale
|
2014-04-10 04:18:06 +00:00
|
|
|
* @param {number} [minX=1] - The minimum value of Particle.scale.x.
|
|
|
|
* @param {number} [maxX=1] - The maximum value of Particle.scale.x.
|
|
|
|
* @param {number} [minY=1] - The minimum value of Particle.scale.y.
|
|
|
|
* @param {number} [maxY=1] - The maximum value of Particle.scale.y.
|
2014-04-10 00:36:05 +00:00
|
|
|
* @param {number} [rate=0] - The rate (in ms) at which the particles will change in scale from min to max, or set to zero to pick a random size between the two.
|
|
|
|
* @param {number} [ease=Phaser.Easing.Linear.None] - If you've set a rate > 0 this is the easing formula applied between the min and max values.
|
|
|
|
* @param {boolean} [yoyo=false] - If you've set a rate > 0 you can set if the ease will yoyo or not (i.e. ease back to its original values)
|
2014-04-09 15:12:25 +00:00
|
|
|
*/
|
2014-04-10 04:18:06 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.setScale = function (minX, maxX, minY, maxY, rate, ease, yoyo) {
|
2014-04-09 15:12:25 +00:00
|
|
|
|
2014-04-10 04:18:06 +00:00
|
|
|
if (typeof minX === 'undefined') { minX = 1; }
|
|
|
|
if (typeof maxX === 'undefined') { maxX = 1; }
|
|
|
|
if (typeof minY === 'undefined') { minY = 1; }
|
|
|
|
if (typeof maxY === 'undefined') { maxY = 1; }
|
2014-04-10 00:36:05 +00:00
|
|
|
if (typeof rate === 'undefined') { rate = 0; }
|
|
|
|
if (typeof ease === 'undefined') { ease = Phaser.Easing.Linear.None; }
|
|
|
|
if (typeof yoyo === 'undefined') { yoyo = false; }
|
2014-04-09 15:12:25 +00:00
|
|
|
|
2014-04-10 04:18:06 +00:00
|
|
|
// Reset these
|
|
|
|
this.minParticleScale = 1;
|
|
|
|
this.maxParticleScale = 1;
|
|
|
|
|
|
|
|
this._minParticleScale.set(minX, minY);
|
|
|
|
this._maxParticleScale.set(maxX, maxY);
|
|
|
|
|
2014-04-10 00:36:05 +00:00
|
|
|
this.autoScale = false;
|
|
|
|
|
2014-04-10 04:18:06 +00:00
|
|
|
if (rate > 0 && (minX !== maxX) || (minY !== maxY))
|
2014-04-10 00:36:05 +00:00
|
|
|
{
|
2014-04-10 04:18:06 +00:00
|
|
|
var tweenData = { x: minX, y: minY };
|
|
|
|
var tween = this.game.make.tween(tweenData).to( { x: maxX, y: maxY }, rate, ease);
|
2014-04-10 00:36:05 +00:00
|
|
|
tween.yoyo(yoyo);
|
|
|
|
|
|
|
|
this.scaleData = tween.generateData(60);
|
|
|
|
|
|
|
|
// Inverse it so we don't have to do array length look-ups in Particle update loops
|
|
|
|
this.scaleData.reverse();
|
|
|
|
this.autoScale = true;
|
|
|
|
}
|
2014-04-09 15:12:25 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
/**
|
2014-01-27 06:29:26 +00:00
|
|
|
* Change the emitters center to match the center of any object with a `center` property, such as a Sprite.
|
2014-04-09 13:29:23 +00:00
|
|
|
* If the object doesn't have a center property it will be set to object.x + object.width / 2
|
|
|
|
*
|
2013-10-02 19:18:24 +00:00
|
|
|
* @method Phaser.Particles.Arcade.Emitter#at
|
2014-04-09 13:29:23 +00:00
|
|
|
* @param {object|Phaser.Sprite|Phaser.Image|Phaser.TileSprite|Phaser.Text|PIXI.DisplayObject} object - The object that you wish to match the center with.
|
2013-10-02 19:18:24 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Phaser.Particles.Arcade.Emitter.prototype.at = function (object) {
|
|
|
|
|
2014-01-27 06:29:26 +00:00
|
|
|
if (object.center)
|
|
|
|
{
|
|
|
|
this.emitX = object.center.x;
|
|
|
|
this.emitY = object.center.y;
|
|
|
|
}
|
2014-04-09 13:29:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
this.emitX = object.world.x + (object.anchor.x * object.width);
|
|
|
|
this.emitY = object.world.y + (object.anchor.y * object.height);
|
|
|
|
}
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2014-03-23 08:26:06 +00:00
|
|
|
};
|
2013-09-10 00:26:50 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* @name Phaser.Particles.Arcade.Emitter#x
|
|
|
|
* @property {number} x - Gets or sets the x position of the Emitter.
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-09-12 19:59:56 +00:00
|
|
|
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "x", {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
return this.emitX;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
this.emitX = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* @name Phaser.Particles.Arcade.Emitter#y
|
|
|
|
* @property {number} y - Gets or sets the y position of the Emitter.
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-09-12 19:59:56 +00:00
|
|
|
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "y", {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
return this.emitY;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
this.emitY = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* @name Phaser.Particles.Arcade.Emitter#left
|
|
|
|
* @property {number} left - Gets the left position of the Emitter.
|
|
|
|
* @readonly
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", {
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
get: function () {
|
|
|
|
return Math.floor(this.x - (this.width / 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* @name Phaser.Particles.Arcade.Emitter#right
|
|
|
|
* @property {number} right - Gets the right position of the Emitter.
|
|
|
|
* @readonly
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", {
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
get: function () {
|
|
|
|
return Math.floor(this.x + (this.width / 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* @name Phaser.Particles.Arcade.Emitter#top
|
|
|
|
* @property {number} top - Gets the top position of the Emitter.
|
|
|
|
* @readonly
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", {
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
get: function () {
|
|
|
|
return Math.floor(this.y - (this.height / 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 19:18:24 +00:00
|
|
|
* @name Phaser.Particles.Arcade.Emitter#bottom
|
|
|
|
* @property {number} bottom - Gets the bottom position of the Emitter.
|
|
|
|
* @readonly
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-09-10 00:26:50 +00:00
|
|
|
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", {
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-09-10 00:26:50 +00:00
|
|
|
get: function () {
|
|
|
|
return Math.floor(this.y + (this.height / 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|