Skip to content

Commit

Permalink
Added jsdocs to Particle and Emitter. Fixed p2 UMD.
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Apr 10, 2014
1 parent c8ca3d1 commit 8bb2255
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
58 changes: 52 additions & 6 deletions src/gameobjects/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,54 @@
/**
* @class Phaser.Particle
*
* @classdesc Create a new `Particle` object. Particles are extended Sprites that are emitted by a particle emitter.
* @classdesc Create a new `Particle` object. Particles are extended Sprites that are emitted by a particle emitter such as Phaser.Particles.Arcade.Emitter.
*
* @constructor
* @extends Phaser.Sprite
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {number} x - The x coordinate (in world space) to position the Sprite at.
* @param {number} y - The y coordinate (in world space) to position the Sprite at.
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
* @param {number} x - The x coordinate (in world space) to position the Particle at.
* @param {number} y - The y coordinate (in world space) to position the Particle at.
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the Particle during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
* @param {string|number} frame - If this Particle is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
*/
Phaser.Particle = function (game, x, y, key, frame) {

Phaser.Sprite.call(this, game, x, y, key, frame);

/**
* @property {boolean} autoScale - If this Particle automatically scales this is set to true by Particle.setScaleData.
* @protected
*/
this.autoScale = false;

/**
* @property {array} scaleData - A reference to the scaleData array owned by the Emitter that emitted this Particle.
* @protected
*/
this.scaleData = null;

/**
* @property {number} _s - Internal cache var for tracking auto scale.
* @private
*/
this._s = 0;

/**
* @property {boolean} autoAlpha - If this Particle automatically changes alpha this is set to true by Particle.setAlphaData.
* @protected
*/
this.autoAlpha = false;

/**
* @property {array} alphaData - A reference to the alphaData array owned by the Emitter that emitted this Particle.
* @protected
*/
this.alphaData = null;

/**
* @property {number} _a - Internal cache var for tracking auto alpha.
* @private
*/
this._a = 0;

};
Expand All @@ -35,7 +63,7 @@ Phaser.Particle.prototype = Object.create(Phaser.Sprite.prototype);
Phaser.Particle.prototype.constructor = Phaser.Particle;

/**
* Override and use this function in your own custom objects to handle any update requirements you may have.
* Updates the Particle scale or alpha if autoScale and autoAlpha are set.
*
* @method Phaser.Particle#update
* @memberof Phaser.Particle
Expand Down Expand Up @@ -72,9 +100,21 @@ Phaser.Particle.prototype.update = function() {

};

/**
* Called by the Emitter when this particle is emitted. Left empty for you to over-ride as required.
*
* @method Phaser.Particle#onEmit
* @memberof Phaser.Particle
*/
Phaser.Particle.prototype.onEmit = function() {
};

/**
* Called by the Emitter if autoAlpha has been enabled. Passes over the alpha ease data and resets the alpha counter.
*
* @method Phaser.Particle#setAlphaData
* @memberof Phaser.Particle
*/
Phaser.Particle.prototype.setAlphaData = function(data) {

this.alphaData = data;
Expand All @@ -84,6 +124,12 @@ Phaser.Particle.prototype.setAlphaData = function(data) {

};

/**
* Called by the Emitter if autoScale has been enabled. Passes over the scale ease data and resets the scale counter.
*
* @method Phaser.Particle#setScaleData
* @memberof Phaser.Particle
*/
Phaser.Particle.prototype.setScaleData = function(data) {

this.scaleData = data;
Expand Down
2 changes: 1 addition & 1 deletion src/particles/arcade/Emitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
Phaser.Group.call(this, game);

/**
* @property {string} name - Description.
* @property {string} name - A handy string name for this emitter. Can be set to anything.
*/
this.name = 'emitter' + this.game.particles.ID++;

Expand Down
2 changes: 1 addition & 1 deletion src/physics/p2/p2.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.p2=e():"undefined"!=typeof global?self.p2=e():"undefined"!=typeof self&&(self.p2=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define('p2', (function() { return this.p2 = e(); })()):"undefined"!=typeof window?window.p2=e():"undefined"!=typeof global?self.p2=e():"undefined"!=typeof self&&(self.p2=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
Expand Down

0 comments on commit 8bb2255

Please sign in to comment.