mirror of
https://github.com/wassname/phaser.git
synced 2026-08-18 12:20:33 +08:00
The entire Phaser library has been updated to match the new JSHint configuration.
This commit is contained in:
+46
-41
@@ -14,61 +14,66 @@
|
||||
*/
|
||||
Phaser.Particles = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Description} emitters - Description.
|
||||
*/
|
||||
this.emitters = {};
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {number} ID - Description.
|
||||
* @default
|
||||
*/
|
||||
this.ID = 0;
|
||||
/**
|
||||
* @property {object} emitters - Internal emitters store.
|
||||
*/
|
||||
this.emitters = {};
|
||||
|
||||
/**
|
||||
* @property {number} ID -
|
||||
* @default
|
||||
*/
|
||||
this.ID = 0;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Particles.prototype = {
|
||||
|
||||
/**
|
||||
* Adds a new Particle Emitter to the Particle Manager.
|
||||
* @method Phaser.Particles#add
|
||||
* @param {Phaser.Emitter} emitter - Description.
|
||||
* @return {Phaser.Emitter} The emitter that was added.
|
||||
*/
|
||||
add: function (emitter) {
|
||||
/**
|
||||
* Adds a new Particle Emitter to the Particle Manager.
|
||||
* @method Phaser.Particles#add
|
||||
* @param {Phaser.Emitter} emitter - The emitter to be added to the particle manager.
|
||||
* @return {Phaser.Emitter} The emitter that was added.
|
||||
*/
|
||||
add: function (emitter) {
|
||||
|
||||
this.emitters[emitter.name] = emitter;
|
||||
this.emitters[emitter.name] = emitter;
|
||||
|
||||
return emitter;
|
||||
return emitter;
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes an existing Particle Emitter from the Particle Manager.
|
||||
* @method Phaser.Particles#remove
|
||||
* @param {Phaser.Emitter} emitter - The emitter to remove.
|
||||
*/
|
||||
remove: function (emitter) {
|
||||
/**
|
||||
* Removes an existing Particle Emitter from the Particle Manager.
|
||||
* @method Phaser.Particles#remove
|
||||
* @param {Phaser.Emitter} emitter - The emitter to remove.
|
||||
*/
|
||||
remove: function (emitter) {
|
||||
|
||||
delete this.emitters[emitter.name];
|
||||
delete this.emitters[emitter.name];
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Called by the core game loop. Updates all Emitters who have their exists value set to true.
|
||||
* @method Phaser.Particles#update
|
||||
* @protected
|
||||
*/
|
||||
update: function () {
|
||||
/**
|
||||
* Called by the core game loop. Updates all Emitters who have their exists value set to true.
|
||||
* @method Phaser.Particles#update
|
||||
* @protected
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
for (var key in this.emitters)
|
||||
{
|
||||
if (this.emitters[key].exists)
|
||||
{
|
||||
this.emitters[key].update();
|
||||
}
|
||||
}
|
||||
for (var key in this.emitters)
|
||||
{
|
||||
if (this.emitters[key].exists)
|
||||
{
|
||||
this.emitters[key].update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
+130
-130
@@ -26,36 +26,36 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
|
||||
* @property {number} maxParticles - The total number of particles in this emitter..
|
||||
* @default
|
||||
*/
|
||||
this.maxParticles = maxParticles || 50;
|
||||
this.maxParticles = maxParticles || 50;
|
||||
|
||||
Phaser.Group.call(this, game);
|
||||
Phaser.Group.call(this, game);
|
||||
|
||||
/**
|
||||
* @property {string} name - Description.
|
||||
*/
|
||||
* @property {string} name - Description.
|
||||
*/
|
||||
this.name = 'emitter' + this.game.particles.ID++;
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.EMITTER;
|
||||
|
||||
/**
|
||||
* @property {number} x - The X position of the top left corner of the emitter in world space.
|
||||
* @default
|
||||
*/
|
||||
* @property {number} x - The X position of the top left corner of the emitter in world space.
|
||||
* @default
|
||||
*/
|
||||
this.x = 0;
|
||||
|
||||
/**
|
||||
* @property {number} y - The Y position of the top left corner of emitter in world space.
|
||||
* @default
|
||||
*/
|
||||
* @property {number} y - The Y position of the top left corner of emitter in world space.
|
||||
* @default
|
||||
*/
|
||||
this.y = 0;
|
||||
|
||||
/**
|
||||
* @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box.
|
||||
* @default
|
||||
*/
|
||||
* @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box.
|
||||
* @default
|
||||
*/
|
||||
this.width = 1;
|
||||
|
||||
/**
|
||||
@@ -87,138 +87,138 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
|
||||
this.minParticleScale = 1;
|
||||
|
||||
/**
|
||||
* The maximum possible scale of a particle.
|
||||
* The default value is 1.
|
||||
* @property {number} maxParticleScale
|
||||
* @default
|
||||
*/
|
||||
* The maximum possible scale of a particle.
|
||||
* The default value is 1.
|
||||
* @property {number} maxParticleScale
|
||||
* @default
|
||||
*/
|
||||
this.maxParticleScale = 1;
|
||||
|
||||
/**
|
||||
* The minimum possible angular velocity of a particle. The default value is -360.
|
||||
* @property {number} minRotation
|
||||
* @default
|
||||
*/
|
||||
* The minimum possible angular velocity of a particle. The default value is -360.
|
||||
* @property {number} minRotation
|
||||
* @default
|
||||
*/
|
||||
this.minRotation = -360;
|
||||
|
||||
/**
|
||||
* The maximum possible angular velocity of a particle. The default value is 360.
|
||||
* @property {number} maxRotation
|
||||
* @default
|
||||
*/
|
||||
* The maximum possible angular velocity of a particle. The default value is 360.
|
||||
* @property {number} maxRotation
|
||||
* @default
|
||||
*/
|
||||
this.maxRotation = 360;
|
||||
|
||||
/**
|
||||
* Sets the <code>gravity.y</code> of each particle to this value on launch.
|
||||
* @property {number} gravity
|
||||
* @default
|
||||
*/
|
||||
* Sets the <code>gravity.y</code> of each particle to this value on launch.
|
||||
* @property {number} gravity
|
||||
* @default
|
||||
*/
|
||||
this.gravity = 2;
|
||||
|
||||
/**
|
||||
* Set your own particle class type here.
|
||||
* @property {Description} particleClass
|
||||
* @default
|
||||
*/
|
||||
* Set your own particle class type here.
|
||||
* @property {Description} particleClass
|
||||
* @default
|
||||
*/
|
||||
this.particleClass = null;
|
||||
|
||||
/**
|
||||
* The X and Y drag component of particles launched from the emitter.
|
||||
* @property {Phaser.Point} particleDrag
|
||||
*/
|
||||
* The X and Y drag component of particles launched from the emitter.
|
||||
* @property {Phaser.Point} particleDrag
|
||||
*/
|
||||
this.particleDrag = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* The angular drag component of particles launched from the emitter if they are rotating.
|
||||
* @property {number} angularDrag
|
||||
* @default
|
||||
*/
|
||||
* The angular drag component of particles launched from the emitter if they are rotating.
|
||||
* @property {number} angularDrag
|
||||
* @default
|
||||
*/
|
||||
this.angularDrag = 0;
|
||||
|
||||
/**
|
||||
* How often a particle is emitted in ms (if emitter is started with Explode === false).
|
||||
* @property {boolean} frequency
|
||||
* @default
|
||||
*/
|
||||
* How often a particle is emitted in ms (if emitter is started with Explode === false).
|
||||
* @property {boolean} frequency
|
||||
* @default
|
||||
*/
|
||||
this.frequency = 100;
|
||||
|
||||
/**
|
||||
* How long each particle lives once it is emitted in ms. Default is 2 seconds.
|
||||
* Set lifespan to 'zero' for particles to live forever.
|
||||
* @property {number} lifespan
|
||||
* @default
|
||||
*/
|
||||
* How long each particle lives once it is emitted in ms. Default is 2 seconds.
|
||||
* Set lifespan to 'zero' for particles to live forever.
|
||||
* @property {number} lifespan
|
||||
* @default
|
||||
*/
|
||||
this.lifespan = 2000;
|
||||
|
||||
/**
|
||||
* How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.
|
||||
* @property {Phaser.Point} bounce
|
||||
*/
|
||||
* How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.
|
||||
* @property {Phaser.Point} bounce
|
||||
*/
|
||||
this.bounce = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* Internal helper for deciding how many particles to launch.
|
||||
* @property {number} _quantity
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
* Internal helper for deciding how many particles to launch.
|
||||
* @property {number} _quantity
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._quantity = 0;
|
||||
|
||||
/**
|
||||
* Internal helper for deciding when to launch particles or kill them.
|
||||
* @property {number} _timer
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
/**
|
||||
* Internal helper for deciding when to launch particles or kill them.
|
||||
* @property {number} _timer
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._timer = 0;
|
||||
|
||||
/**
|
||||
* Internal counter for figuring out how many particles to launch.
|
||||
* @property {number} _counter
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
* Internal counter for figuring out how many particles to launch.
|
||||
* @property {number} _counter
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._counter = 0;
|
||||
|
||||
/**
|
||||
* Internal helper for the style of particle emission (all at once, or one at a time).
|
||||
* @property {boolean} _explode
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
* Internal helper for the style of particle emission (all at once, or one at a time).
|
||||
* @property {boolean} _explode
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._explode = true;
|
||||
|
||||
/**
|
||||
* Determines whether the emitter is currently emitting particles.
|
||||
* It is totally safe to directly toggle this.
|
||||
* @property {boolean} on
|
||||
* @default
|
||||
*/
|
||||
* Determines whether the emitter is currently emitting particles.
|
||||
* It is totally safe to directly toggle this.
|
||||
* @property {boolean} on
|
||||
* @default
|
||||
*/
|
||||
this.on = false;
|
||||
|
||||
/**
|
||||
* Determines whether the emitter is being updated by the core game loop.
|
||||
* @property {boolean} exists
|
||||
* @default
|
||||
*/
|
||||
* Determines whether the emitter is being updated by the core game loop.
|
||||
* @property {boolean} exists
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
/**
|
||||
* 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 {boolean} emitX
|
||||
*/
|
||||
* 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 {boolean} 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 {boolean} emitY
|
||||
*/
|
||||
* 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 {boolean} emitY
|
||||
*/
|
||||
this.emitY = y;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Phaser.Particles.Arcade.Emitter.prototype = Object.create(Phaser.Group.prototype);
|
||||
@@ -234,12 +234,12 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () {
|
||||
{
|
||||
if (this._explode)
|
||||
{
|
||||
this._counter = 0;
|
||||
this._counter = 0;
|
||||
|
||||
do
|
||||
{
|
||||
this.emitParticle();
|
||||
this._counter++;
|
||||
this.emitParticle();
|
||||
this._counter++;
|
||||
}
|
||||
while (this._counter < this._quantity);
|
||||
|
||||
@@ -247,22 +247,22 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.game.time.now >= this._timer)
|
||||
{
|
||||
if (this.game.time.now >= this._timer)
|
||||
{
|
||||
this.emitParticle();
|
||||
|
||||
this._counter++;
|
||||
|
||||
this._counter++;
|
||||
|
||||
if (this._quantity > 0)
|
||||
{
|
||||
if (this._counter >= this._quantity)
|
||||
{
|
||||
this.on = false;
|
||||
}
|
||||
if (this._counter >= this._quantity)
|
||||
{
|
||||
this.on = false;
|
||||
}
|
||||
}
|
||||
|
||||
this._timer = this.game.time.now + this.frequency;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
|
||||
frames = 0;
|
||||
}
|
||||
|
||||
quantity = quantity || this.maxParticles;
|
||||
quantity = quantity || this.maxParticles;
|
||||
collide = collide || 0;
|
||||
|
||||
if (typeof collideWorldBounds == 'undefined')
|
||||
@@ -315,10 +315,10 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
|
||||
|
||||
particle = new Phaser.Sprite(this.game, 0, 0, rndKey, rndFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
// else
|
||||
// {
|
||||
// particle = new this.particleClass(this.game);
|
||||
}
|
||||
// }
|
||||
|
||||
if (collide > 0)
|
||||
{
|
||||
@@ -380,18 +380,18 @@ Phaser.Particles.Arcade.Emitter.prototype.revive = function () {
|
||||
*/
|
||||
Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity) {
|
||||
|
||||
if (typeof explode !== 'boolean')
|
||||
{
|
||||
explode = true;
|
||||
}
|
||||
if (typeof explode !== 'boolean')
|
||||
{
|
||||
explode = true;
|
||||
}
|
||||
|
||||
lifespan = lifespan || 0;
|
||||
lifespan = lifespan || 0;
|
||||
|
||||
// How many ms between emissions?
|
||||
frequency = frequency || 250;
|
||||
// How many ms between emissions?
|
||||
frequency = frequency || 250;
|
||||
|
||||
// Total number of particles to emit
|
||||
quantity = quantity || 0;
|
||||
// Total number of particles to emit
|
||||
quantity = quantity || 0;
|
||||
|
||||
this.revive();
|
||||
|
||||
@@ -426,16 +426,16 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
|
||||
|
||||
if (particle == null)
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.width > 1 || this.height > 1)
|
||||
{
|
||||
particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom));
|
||||
particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.reset(this.emitX, this.emitY);
|
||||
particle.reset(this.emitX, this.emitY);
|
||||
}
|
||||
|
||||
particle.lifespan = this.lifespan;
|
||||
@@ -504,8 +504,8 @@ Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) {
|
||||
*/
|
||||
Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) {
|
||||
|
||||
min = min || 0;
|
||||
max = max || 0;
|
||||
min = min || 0;
|
||||
max = max || 0;
|
||||
|
||||
this.minParticleSpeed.x = min;
|
||||
this.maxParticleSpeed.x = max;
|
||||
@@ -520,8 +520,8 @@ Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) {
|
||||
*/
|
||||
Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) {
|
||||
|
||||
min = min || 0;
|
||||
max = max || 0;
|
||||
min = min || 0;
|
||||
max = max || 0;
|
||||
|
||||
this.minParticleSpeed.y = min;
|
||||
this.maxParticleSpeed.y = max;
|
||||
@@ -536,8 +536,8 @@ Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) {
|
||||
*/
|
||||
Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) {
|
||||
|
||||
min = min || 0;
|
||||
max = max || 0;
|
||||
min = min || 0;
|
||||
max = max || 0;
|
||||
|
||||
this.minRotation = min;
|
||||
this.maxRotation = max;
|
||||
|
||||
Reference in New Issue
Block a user