More jsdoc updates

This commit is contained in:
Richard Davey 2018-02-01 05:48:56 +00:00
parent 9e8ee078e8
commit 99913b9da4
6 changed files with 313 additions and 39 deletions

View file

@ -1,15 +1,41 @@
var Class = require('../utils/Class'); var Class = require('../utils/Class');
var PluginManager = require('../plugins/PluginManager'); var PluginManager = require('../plugins/PluginManager');
/**
* [description]
*
* @class GameObjectFactory
* @memberOf Phaser.GameObjects
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs.
*/
var GameObjectFactory = new Class({ var GameObjectFactory = new Class({
initialize: initialize:
function GameObjectFactory (scene) function GameObjectFactory (scene)
{ {
// The Scene that owns this plugin /**
* The Scene to which this Game Object belongs.
* Game Objects can only belong to one Scene.
*
* @name Phaser.GameObjects.GameObjectFactory#scene
* @type {Phaser.Scene}
* @protected
* @since 3.0.0
*/
this.scene = scene; this.scene = scene;
/**
* A reference to the Scene.Systems.
*
* @name Phaser.GameObjects.GameObjectFactory#systems
* @type {Phaser.Scenes.Systems}
* @protected
* @since 3.0.0
*/
this.systems = scene.sys; this.systems = scene.sys;
if (!scene.sys.settings.isBooted) if (!scene.sys.settings.isBooted)
@ -18,9 +44,17 @@ var GameObjectFactory = new Class({
} }
this.displayList; this.displayList;
this.updateList; this.updateList;
}, },
/**
* Boots the plugin.
*
* @method Phaser.GameObjects.GameObjectFactory#boot
* @private
* @since 3.0.0
*/
boot: function () boot: function ()
{ {
this.displayList = this.systems.displayList; this.displayList = this.systems.displayList;
@ -32,6 +66,19 @@ var GameObjectFactory = new Class({
eventEmitter.on('destroy', this.destroy, this); eventEmitter.on('destroy', this.destroy, this);
}, },
/**
* Adds an existing Game Object to this Scene.
*
* If the Game Object renders, it will be added to the Display List.
* If it has a `preUpdate` method, it will be added to the Update List.
*
* @method Phaser.GameObjects.GameObjectFactory#existing
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} child - The child to be added to this Scene.
*
* @return {Phaser.GameObjects.GameObject} The Game Object that was added.
*/
existing: function (child) existing: function (child)
{ {
if (child.renderCanvas || child.renderWebGL) if (child.renderCanvas || child.renderWebGL)
@ -47,11 +94,22 @@ var GameObjectFactory = new Class({
return child; return child;
}, },
/**
* Shuts this plugin down.
*
* @method Phaser.GameObjects.GameObjectFactory#shutdown
* @since 3.0.0
*/
shutdown: function () shutdown: function ()
{ {
// TODO
}, },
/**
* Destroys this plugin.
*
* @method Phaser.GameObjects.GameObjectFactory#destroy
* @since 3.0.0
*/
destroy: function () destroy: function ()
{ {
this.scene = null; this.scene = null;

View file

@ -125,19 +125,18 @@ var Blitter = new Class({
return bob; return bob;
}, },
// frame MUST be part of the Blitter texture
/** /**
* [description] * [description]
* *
* @method Phaser.GameObjects.Blitter#createFromCallback * @method Phaser.GameObjects.Blitter#createFromCallback
* @since 3.0.0 * @since 3.0.0
* *
* @param {[type]} callback - [description] * @param {function} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob.
* @param {[type]} quantity - [description] * @param {integer} quantity - The quantity of Bob objects to create.
* @param {[type]} frame - [description] * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture.
* @param {[type]} visible - [description] * @param {boolean} [visible=true] - [description]
* *
* @return {[type]} [description] * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created.
*/ */
createFromCallback: function (callback, quantity, frame, visible) createFromCallback: function (callback, quantity, frame, visible)
{ {
@ -153,18 +152,17 @@ var Blitter = new Class({
return bobs; return bobs;
}, },
// frame MUST be part of the Blitter texture
/** /**
* [description] * [description]
* *
* @method Phaser.GameObjects.Blitter#createMultiple * @method Phaser.GameObjects.Blitter#createMultiple
* @since 3.0.0 * @since 3.0.0
* *
* @param {[type]} quantity - [description] * @param {integer} quantity - The quantity of Bob objects to create.
* @param {[type]} frame - [description] * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture.
* @param {[type]} visible - [description] * @param {boolean} [visible=true] - [description]
* *
* @return {[type]} [description] * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created.
*/ */
createMultiple: function (quantity, frame, visible) createMultiple: function (quantity, frame, visible)
{ {
@ -196,9 +194,9 @@ var Blitter = new Class({
* @method Phaser.GameObjects.Blitter#childCanRender * @method Phaser.GameObjects.Blitter#childCanRender
* @since 3.0.0 * @since 3.0.0
* *
* @param {[type]} child - [description] * @param {Phaser.GameObjects.Blitter.Bob} child - [description]
* *
* @return {[type]} [description] * @return {boolean} [description]
*/ */
childCanRender: function (child) childCanRender: function (child)
{ {

View file

@ -3,8 +3,18 @@ var BuildGameObject = require('../BuildGameObject');
var GameObjectCreator = require('../GameObjectCreator'); var GameObjectCreator = require('../GameObjectCreator');
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue'); var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
// When registering a factory function 'this' refers to the GameObjectCreator context. /**
* Creates a new Blitter Game Object and returns it.
*
* Note: This method will only be available if the Blitter Game Object has been built into Phaser.
*
* @method Phaser.GameObjects.GameObjectCreator#blitter
* @since 3.0.0
*
* @param {object} config - [description]
*
* @return {Phaser.GameObjects.Blitter} The Game Object that was created.
*/
GameObjectCreator.register('blitter', function (config) GameObjectCreator.register('blitter', function (config)
{ {
var key = GetAdvancedValue(config, 'key', null); var key = GetAdvancedValue(config, 'key', null);
@ -16,3 +26,5 @@ GameObjectCreator.register('blitter', function (config)
return blitter; return blitter;
}); });
// When registering a factory function 'this' refers to the GameObjectCreator context.

View file

@ -1,6 +1,26 @@
var Blitter = require('./Blitter'); var Blitter = require('./Blitter');
var GameObjectFactory = require('../GameObjectFactory'); var GameObjectFactory = require('../GameObjectFactory');
/**
* Creates a new Blitter Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Blitter Game Object has been built into Phaser.
*
* @method Phaser.GameObjects.GameObjectFactory#blitter
* @since 3.0.0
*
* @param {number} x - The x position of the Game Object.
* @param {number} y - The y position of the Game Object.
* @param {string} key - The key of the Texture the Blitter object will use.
* @param {string|integer} [frame] - The default Frame children of the Blitter will use.
*
* @return {Phaser.GameObjects.Blitter} The Game Object that was created.
*/
GameObjectFactory.register('blitter', function (x, y, key, frame)
{
return this.displayList.add(new Blitter(this.scene, x, y, key, frame));
});
// When registering a factory function 'this' refers to the GameObjectFactory context. // When registering a factory function 'this' refers to the GameObjectFactory context.
// //
// There are several properties available to use: // There are several properties available to use:
@ -8,8 +28,3 @@ var GameObjectFactory = require('../GameObjectFactory');
// this.scene - a reference to the Scene that owns the GameObjectFactory // this.scene - a reference to the Scene that owns the GameObjectFactory
// this.displayList - a reference to the Display List the Scene owns // this.displayList - a reference to the Display List the Scene owns
// this.updateList - a reference to the Update List the Scene owns // this.updateList - a reference to the Update List the Scene owns
GameObjectFactory.register('blitter', function (x, y, key, frame)
{
return this.displayList.add(new Blitter(this.scene, x, y, key, frame));
});

View file

@ -1,25 +1,121 @@
var Class = require('../../utils/Class'); var Class = require('../../utils/Class');
/**
* [description]
*
* @class Bob
* @memberOf Phaser.GameObjects.Blitter
* @constructor
* @since 3.0.0
*
* @param {Phaser.GameObjects.Blitter} blitter - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {string|integer} frame - [description]
* @param {boolean} visible - [description]
*/
var Bob = new Class({ var Bob = new Class({
initialize: initialize:
function Bob (blitter, x, y, frame, visible) function Bob (blitter, x, y, frame, visible)
{ {
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#parent
* @type {Phaser.GameObjects.Blitter}
* @since 3.0.0
*/
this.parent = blitter; this.parent = blitter;
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#x
* @type {number}
* @since 3.0.0
*/
this.x = x; this.x = x;
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#y
* @type {number}
* @since 3.0.0
*/
this.y = y; this.y = y;
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#frame
* @type {string|integer}
* @since 3.0.0
*/
this.frame = frame; this.frame = frame;
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#data
* @type {object}
* @default {}
* @since 3.0.0
*/
this.data = {}; this.data = {};
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#_visible
* @type {boolean}
* @private
* @since 3.0.0
*/
this._visible = visible; this._visible = visible;
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#_alpha
* @type {number}
* @private
* @default 1
* @since 3.0.0
*/
this._alpha = 1; this._alpha = 1;
this.flipX - false; /**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#flipX
* @type {boolean}
* @since 3.0.0
*/
this.flipX = false;
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#flipY
* @type {boolean}
* @since 3.0.0
*/
this.flipY = false; this.flipY = false;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#setFrame
* @since 3.0.0
*
* @param {[type]} frame - [description]
*
* @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object.
*/
setFrame: function (frame) setFrame: function (frame)
{ {
if (frame === undefined) if (frame === undefined)
@ -34,19 +130,53 @@ var Bob = new Class({
return this; return this;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#resetFlip
* @since 3.0.0
*
* @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object.
*/
resetFlip: function () resetFlip: function ()
{ {
this.flipX = false; this.flipX = false;
this.flipY = false; this.flipY = false;
return this;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#reset
* @since 3.0.0
*
* @param {[type]} x - [description]
* @param {[type]} y - [description]
* @param {[type]} frame - [description]
*
* @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object.
*/
reset: function (x, y, frame) reset: function (x, y, frame)
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.frame = frame; this.frame = frame;
return this;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#setFlipX
* @since 3.0.0
*
* @param {[type]} value - [description]
*
* @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object.
*/
setFlipX: function (value) setFlipX: function (value)
{ {
this.flipX = value; this.flipX = value;
@ -54,6 +184,16 @@ var Bob = new Class({
return this; return this;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#setFlipY
* @since 3.0.0
*
* @param {[type]} value - [description]
*
* @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object.
*/
setFlipY: function (value) setFlipY: function (value)
{ {
this.flipY = value; this.flipY = value;
@ -61,6 +201,17 @@ var Bob = new Class({
return this; return this;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#setFlip
* @since 3.0.0
*
* @param {[type]} x - [description]
* @param {[type]} y - [description]
*
* @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object.
*/
setFlip: function (x, y) setFlip: function (x, y)
{ {
this.flipX = x; this.flipX = x;
@ -69,6 +220,16 @@ var Bob = new Class({
return this; return this;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#setVisible
* @since 3.0.0
*
* @param {[type]} value - [description]
*
* @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object.
*/
setVisible: function (value) setVisible: function (value)
{ {
this.visible = value; this.visible = value;
@ -76,6 +237,16 @@ var Bob = new Class({
return this; return this;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#setAlpha
* @since 3.0.0
*
* @param {[type]} value - [description]
*
* @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object.
*/
setAlpha: function (value) setAlpha: function (value)
{ {
this.alpha = value; this.alpha = value;
@ -83,6 +254,12 @@ var Bob = new Class({
return this; return this;
}, },
/**
* [description]
*
* @method Phaser.GameObjects.Blitter.Bob#destroy
* @since 3.0.0
*/
destroy: function () destroy: function ()
{ {
this.parent.dirty = true; this.parent.dirty = true;
@ -94,6 +271,13 @@ var Bob = new Class({
this.data = undefined; this.data = undefined;
}, },
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#visible
* @type {boolean}
* @since 3.0.0
*/
visible: { visible: {
get: function () get: function ()
@ -109,6 +293,13 @@ var Bob = new Class({
}, },
/**
* [description]
*
* @name Phaser.GameObjects.Blitter.Bob#alpha
* @type {number}
* @since 3.0.0
*/
alpha: { alpha: {
get: function () get: function ()

View file

@ -4,11 +4,7 @@ var GetPoint = require('./GetPoint');
var GetPoints = require('./GetPoints'); var GetPoints = require('./GetPoints');
var Random = require('./Random'); var Random = require('./Random');
var Circle = new Class({ /**
initialize:
/**
* A Circle object. * A Circle object.
* *
* This is a geometry object, containing numerical values and related methods to inspect and modify them. * This is a geometry object, containing numerical values and related methods to inspect and modify them.
@ -24,6 +20,10 @@ var Circle = new Class({
* @param {number} [y=0] - The y position of the center of the circle. * @param {number} [y=0] - The y position of the center of the circle.
* @param {number} [radius=0] - The radius of the circle. * @param {number} [radius=0] - The radius of the circle.
*/ */
var Circle = new Class({
initialize:
function Circle (x, y, radius) function Circle (x, y, radius)
{ {
if (x === undefined) { x = 0; } if (x === undefined) { x = 0; }