mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Emitter.start has a new parameter: forceQuantity which will force the quantity of a flow of particles to be the given value (request #853)
Emitter.explode is a new short-cut for exploding a fixed quantity of particles at once. Emitter.flow is a new short-cut for creating a flow of particles based on the given frequency.
This commit is contained in:
parent
12252944fa
commit
1c9e23f535
3 changed files with 45 additions and 10 deletions
|
@ -63,6 +63,7 @@ Version 2.0.6 - "Jornhill" - -in development-
|
|||
* Stage no longer creates the Phaser.Canvas object, but Game itself does in the setupRenderer method.
|
||||
* Canvas.create has deprecated the noCocoon parameter as it's no longer required. The parameter is still in the signature, but no longer used in the method.
|
||||
* Time.add allows you to add an existing Phaser.Timer to the timer pool (request #864)
|
||||
* Emitter.start has a new parameter: forceQuantity which will force the quantity of a flow of particles to be the given value (request #853)
|
||||
|
||||
### CocoonJS Specific Updates
|
||||
|
||||
|
@ -88,6 +89,8 @@ Version 2.0.6 - "Jornhill" - -in development-
|
|||
* Loader.pack will allow you to load in a new Phaser Asset Pack JSON file. An Asset Pack is a specially structured file that allows you to define all assets for your game in an external file. The file can be split into sections, allowing you to control loading a specific set of files from it. An example JSON file can be found in the `resources\Asset Pack JSON Format` folder and examples of use in the Phaser Examples repository.
|
||||
* Loader.totalQueuedPacks returns the number of Asset Packs in the queue.
|
||||
* Loader.totalLoadedPacks returns the number of Asset Packs already loaded.
|
||||
* Emitter.explode is a new short-cut for exploding a fixed quantity of particles at once.
|
||||
* Emitter.flow is a new short-cut for creating a flow of particles based on the given frequency.
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
|
4
build/phaser.d.ts
vendored
4
build/phaser.d.ts
vendored
|
@ -2931,6 +2931,8 @@ declare module Phaser {
|
|||
|
||||
at(object: any): void;
|
||||
emitParticle(): void;
|
||||
explode(lifespan?: number, quantity?: number): void;
|
||||
flow(lifespan?: number, frequency?: number, quantity?: number): void;
|
||||
kill(): void;
|
||||
makeParticles(keys: any, frames?: any, quantity?: number, collide?: boolean, collideWorldBounds?: boolean): Phaser.Particles.Arcade.Emitter;
|
||||
reset(x: number, y: number, health?: number): Phaser.Particles;
|
||||
|
@ -2940,7 +2942,7 @@ declare module Phaser {
|
|||
setSize(width: number, height: number): void;
|
||||
setXSpeed(min: number, max: number): void;
|
||||
setYSpeed(min: number, max: number): void;
|
||||
start(explode?: boolean, lifespan?: number, frequency?: number, quantity?: number): void;
|
||||
start(explode?: boolean, lifespan?: number, frequency?: number, quantity?: number, forceQuantity?: boolean): void;
|
||||
update(): void;
|
||||
revive(): void;
|
||||
|
||||
|
|
|
@ -5,24 +5,24 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Phaser - ArcadeEmitter
|
||||
*
|
||||
* @class Phaser.Particles.Arcade.Emitter
|
||||
* @classdesc Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
|
||||
* 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.
|
||||
*
|
||||
* @classdesc Emitter is a lightweight particle emitter that uses Arcade Physics.
|
||||
* It can be used for one-time explosions or for 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.
|
||||
*
|
||||
* @constructor
|
||||
* @extends Phaser.Group
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @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..
|
||||
* @param {number} [maxParticles=50] - The total number of particles in this emitter.
|
||||
*/
|
||||
|
||||
Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
|
||||
|
||||
/**
|
||||
* @property {number} maxParticles - The total number of particles in this emitter..
|
||||
* @property {number} maxParticles - The total number of particles in this emitter.
|
||||
* @default
|
||||
*/
|
||||
this.maxParticles = maxParticles || 50;
|
||||
|
@ -398,20 +398,50 @@ Phaser.Particles.Arcade.Emitter.prototype.revive = function () {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to emit the given quantity of particles at all once (an explosion)
|
||||
*
|
||||
* @method Phaser.Particles.Arcade.Emitter#explode
|
||||
* @param {number} [lifespan=0] - How long each particle lives once emitted in ms. 0 = forever.
|
||||
* @param {number} [quantity=0] - How many particles to launch.
|
||||
*/
|
||||
Phaser.Particles.Arcade.Emitter.prototype.explode = function (lifespan, quantity) {
|
||||
|
||||
this.start(true, lifespan, 0, quantity, false);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to start emitting a flow of particles at the given frequency.
|
||||
*
|
||||
* @method Phaser.Particles.Arcade.Emitter#flow
|
||||
* @param {number} [lifespan=0] - How long each particle lives once emitted in ms. 0 = forever.
|
||||
* @param {number} [frequency=250] - Frequency is how often to emit a particle, given in ms.
|
||||
* @param {number} [quantity=0] - How many particles to launch.
|
||||
*/
|
||||
Phaser.Particles.Arcade.Emitter.prototype.flow = function (lifespan, frequency, quantity) {
|
||||
|
||||
this.start(false, lifespan, frequency, quantity, true);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to start emitting particles.
|
||||
*
|
||||
* @method Phaser.Particles.Arcade.Emitter#start
|
||||
* @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.
|
||||
* @param {number} [frequency=250] - Ignored if Explode is set to true. Frequency is how often to emit 1 particle. Value given in ms.
|
||||
* @param {number} [quantity=0] - How many particles to launch. 0 = "all of the particles".
|
||||
* @param {number} [forceQuantity=false] - If true and creating a particle flow, the quantity emitted will be forced to the be quantity given in this call.
|
||||
*/
|
||||
Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity) {
|
||||
Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity, forceQuantity) {
|
||||
|
||||
if (typeof explode === 'undefined') { explode = true; }
|
||||
if (typeof lifespan === 'undefined') { lifespan = 0; }
|
||||
if (typeof frequency === 'undefined' || frequency === null) { frequency = 250; }
|
||||
if (typeof quantity === 'undefined') { quantity = 0; }
|
||||
if (typeof forceQuantity === 'undefined') { forceQuantity = false; }
|
||||
|
||||
this.revive();
|
||||
|
||||
|
@ -422,7 +452,7 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f
|
|||
this.lifespan = lifespan;
|
||||
this.frequency = frequency;
|
||||
|
||||
if (explode)
|
||||
if (explode || forceQuantity)
|
||||
{
|
||||
this._quantity = quantity;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue