phaser/src/particles/Particles.js

74 lines
1.5 KiB
JavaScript
Raw Normal View History

2013-10-01 13:54:29 +01:00
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
2013-10-02 20:18:24 +01:00
* Phaser.Particles is the Particle Manager for the game. It is called during the game update loop and in turn updates any Emitters attached to it.
*
2013-10-01 13:54:29 +01:00
* @class Phaser.Particles
* @classdesc Phaser Particles
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
*/
Phaser.Particles = function (game) {
2013-10-01 13:54:29 +01:00
/**
* @property {Description} emitters - Description.
*/
this.emitters = {};
2013-10-01 13:54:29 +01:00
/**
* @property {number} ID - Description.
* @default
*/
this.ID = 0;
};
Phaser.Particles.prototype = {
2013-10-01 13:54:29 +01:00
/**
2013-10-02 20:18:24 +01:00
* 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.
2013-10-01 13:54:29 +01:00
*/
add: function (emitter) {
this.emitters[emitter.name] = emitter;
return emitter;
},
2013-10-01 13:54:29 +01:00
/**
2013-10-02 20:18:24 +01:00
* Removes an existing Particle Emitter from the Particle Manager.
* @method Phaser.Particles#remove
* @param {Phaser.Emitter} emitter - The emitter to remove.
2013-10-01 13:54:29 +01:00
*/
remove: function (emitter) {
delete this.emitters[emitter.name];
},
2013-10-01 13:54:29 +01:00
/**
2013-10-02 20:18:24 +01:00
* Called by the core game loop. Updates all Emitters who have their exists value set to true.
* @method Phaser.Particles#update
* @protected
2013-10-01 13:54:29 +01:00
*/
update: function () {
for (var key in this.emitters)
{
if (this.emitters[key].exists)
{
this.emitters[key].update();
}
}
2013-10-02 20:18:24 +01:00
}
};