More docs.

This commit is contained in:
Richard Davey
2013-10-02 12:11:22 +01:00
parent 2a01fbb0e8
commit 852e82d0ca
60 changed files with 39127 additions and 362 deletions
+1
View File
@@ -1057,6 +1057,7 @@ Phaser.Group.prototype = {
/**
* @name Phaser.Group#length
* @property {number} length - The number of children in this Group.
* @readonly
*/
Object.defineProperty(Phaser.Group.prototype, "length", {
+6 -12
View File
@@ -2,15 +2,13 @@
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.Stage
*/
/**
*
* The Stage controls the canvas on which everything is displayed. It handles display within the browser,
* focus handling, game resizing, scaling and the pause, boot and orientation screens.
*
* @class Stage
* @class Phaser.Stage
* @constructor
* @param {Phaser.Game} game - Game reference to the currently running game.
* @param {number} width - Width of the canvas element.
@@ -69,7 +67,8 @@ Phaser.Stage.prototype = {
/**
* Initialises the stage and adds the event listeners.
* @method boot
* @method Phaser.Stage#boot
* @private
*/
boot: function () {
@@ -98,7 +97,7 @@ Phaser.Stage.prototype = {
/**
* This method is called when the document visibility is changed.
* @method visibilityChange
* @method Phaser.Stage#visibilityChange
* @param {Event} event - Its type will be used to decide whether the game should be paused or not.
*/
visibilityChange: function (event) {
@@ -110,12 +109,10 @@ Phaser.Stage.prototype = {
if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true)
{
// console.log('visibilityChange - hidden', event);
this.game.paused = true;
}
else
{
// console.log('visibilityChange - shown', event);
this.game.paused = false;
}
@@ -124,11 +121,8 @@ Phaser.Stage.prototype = {
};
/**
* Get
* @returns {string} Returns the background color of the stage.
*//**
* Set
* @param {string} The background color you want the stage to have
* @name Phaser.Stage#backgroundColor
* @property {number|string} paused - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000'
*/
Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
+11 -12
View File
@@ -2,10 +2,8 @@
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.State
*/
/**
* This is a base State class which can be extended if you are creating your own game.
* It provides quick access to common functions such as the camera, cache, input, match, sound and more.
@@ -15,13 +13,14 @@
*/
Phaser.State = function () {
/**
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = null;
/**
* @property {Description} add - Description.
* @property {Phaser.GameObjectFactory} add - Reference to the GameObjectFactory.
* @default
*/
this.add = null;
@@ -106,7 +105,7 @@ Phaser.State.prototype = {
* Override this method to add some load operations.
* If you need to use the loader, you may need to use them here.
*
* @method preload
* @method Phaser.State#preload
*/
preload: function () {
},
@@ -114,7 +113,7 @@ Phaser.State.prototype = {
/**
* Put update logic here.
*
* @method loadUpdate
* @method Phaser.State#loadUpdate
*/
loadUpdate: function () {
},
@@ -122,7 +121,7 @@ Phaser.State.prototype = {
/**
* Put render operations here.
*
* @method loadRender
* @method Phaser.State#loadRender
*/
loadRender: function () {
},
@@ -131,7 +130,7 @@ Phaser.State.prototype = {
* This method is called after the game engine successfully switches states.
* Feel free to add any setup code here (do not load anything here, override preload() instead).
*
* @method create
* @method Phaser.State#create
*/
create: function () {
},
@@ -139,7 +138,7 @@ Phaser.State.prototype = {
/**
* Put update logic here.
*
* @method update
* @method Phaser.State#update
*/
update: function () {
},
@@ -147,7 +146,7 @@ Phaser.State.prototype = {
/**
* Put render operations here.
*
* @method render
* @method Phaser.State#render
*/
render: function () {
},
@@ -155,14 +154,14 @@ Phaser.State.prototype = {
/**
* This method will be called when game paused.
*
* @method paused
* @method Phaser.State#paused
*/
paused: function () {
},
/**
* This method will be called when the state is destroyed.#
* @method destroy
* This method will be called when the state is destroyed.
* @method Phaser.State#destroy
*/
destroy: function () {
}
+26 -24
View File
@@ -2,16 +2,15 @@
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.StateManager
*/
/**
* Description.
* The State Manager is responsible for loading, setting up and switching game states.
*
* @class Phaser.StateManager
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {Description} pendingState - Description.
* @param {Phaser.State|Object} [pendingState=null] - A State object to seed the manager with.
*/
Phaser.StateManager = function (game, pendingState) {
@@ -130,7 +129,8 @@ Phaser.StateManager.prototype = {
/**
* Description.
* @method boot
* @method Phaser.StateManager#boot
* @private
*/
boot: function () {
@@ -157,7 +157,7 @@ Phaser.StateManager.prototype = {
/**
* Add a new State.
* @method add
* @method Phaser.StateManager#add
* @param key {string} - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
* @param state {State} - The state you want to switch to.
* @param autoStart {boolean} - Start the state immediately after creating it? (default true)
@@ -211,7 +211,7 @@ Phaser.StateManager.prototype = {
/**
* Delete the given state.
* @method remove
* @method Phaser.StateManager#remove
* @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
*/
remove: function (key) {
@@ -239,7 +239,7 @@ Phaser.StateManager.prototype = {
/**
* Start the given state
* @method start
* @method Phaser.StateManager#start
* @param {string} key - The key of the state you want to start.
* @param {boolean} [clearWorld] - clear everything in the world? (Default to true)
* @param {boolean} [clearCache] - clear asset cache? (Default to false and ONLY available when clearWorld=true)
@@ -317,7 +317,7 @@ Phaser.StateManager.prototype = {
/**
* Used by onInit and onShutdown when those functions don't exist on the state
* @method dummy
* @method Phaser.StateManager#dummy
* @private
*/
dummy: function () {
@@ -325,7 +325,7 @@ Phaser.StateManager.prototype = {
/**
* Description.
* @method checkState
* @method Phaser.StateManager#checkState
* @param {string} key - The key of the state you want to check.
* @return {boolean} Description.
*/
@@ -362,9 +362,10 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method link
* @param {string} key - Description.
* Links game properties to the State given by the key.
* @method Phaser.StateManager#link
* @param {string} key - State key.
* @protected
*/
link: function (key) {
@@ -388,9 +389,10 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method setCurrentState
* @param {string} key - Description.
* Sets the current State. Should not be called directly (use StateManager.start)
* @method Phaser.StateManager#setCurrentState
* @param {string} key - State key.
* @protected
*/
setCurrentState: function (key) {
@@ -421,8 +423,8 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method loadComplete
* @method Phaser.StateManager#loadComplete
* @protected
*/
loadComplete: function () {
@@ -442,8 +444,8 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method update
* @method Phaser.StateManager#update
* @protected
*/
update: function () {
@@ -462,8 +464,8 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method preRender
* @method Phaser.StateManager#preRender
* @protected
*/
preRender: function () {
@@ -475,8 +477,8 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method render
* @method Phaser.StateManager#render
* @protected
*/
render: function () {
@@ -496,7 +498,7 @@ Phaser.StateManager.prototype = {
/**
* Nuke the entire game from orbit
* @method destroy
* @method Phaser.StateManager#destroy
*/
destroy: function () {
+22 -34
View File
@@ -2,11 +2,9 @@
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.World
*/
/**
*
* "This world is but a canvas to our imagination." - Henry David Thoreau
* <p>
* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
@@ -51,7 +49,8 @@ Phaser.World.prototype = {
/**
* Initialises the game world.
*
* @method boot
* @method Phaser.World#boot
* @protected
*/
boot: function () {
@@ -66,7 +65,7 @@ Phaser.World.prototype = {
/**
* This is called automatically every frame, and is where main logic happens.
*
* @method update
* @method Phaser.World#update
*/
update: function () {
@@ -99,7 +98,7 @@ Phaser.World.prototype = {
/**
* This is called automatically every frame, and is where main logic happens.
* @method update
* @method Phaser.World#postUpdate
*/
postUpdate: function () {
@@ -123,7 +122,7 @@ Phaser.World.prototype = {
/**
* Updates the size of this world.
* @method setSize
* @method Phaser.World#setSize
* @param {number} width - New width of the world.
* @param {number} height - New height of the world.
*/
@@ -143,7 +142,7 @@ Phaser.World.prototype = {
/**
* Destroyer of worlds.
* @method destroy
* @method Phaser.World#destroy
*/
destroy: function () {
@@ -158,28 +157,16 @@ Phaser.World.prototype = {
};
// Getters / Setters
/**
* Get
* @returns {Description}
*//**
* Set
* @param {Description} value - Description
* @name Phaser.World#width
* @property {number} width - Gets or sets the current width of the game world.
*/
Object.defineProperty(Phaser.World.prototype, "width", {
/**
* @method width
* @return {number} The current width of the game world
*/
get: function () {
return this.bounds.width;
},
/**
* @method width
* @return {number} Sets the width of the game world
*/
set: function (value) {
this.bounds.width = value;
}
@@ -187,11 +174,8 @@ Object.defineProperty(Phaser.World.prototype, "width", {
});
/**
* Get
* @returns {number} The current height of the game world.
*//**
* Sets the width of the game world.
* @param {Description} value - Height of the game world.
* @name Phaser.World#height
* @property {number} height - Gets or sets the current height of the game world.
*/
Object.defineProperty(Phaser.World.prototype, "height", {
@@ -206,8 +190,9 @@ Object.defineProperty(Phaser.World.prototype, "height", {
});
/**
* Get
* @returns {number} return the X position of the center point of the world
* @name Phaser.World#centerX
* @property {number} centerX - Gets the X position corresponding to the center point of the world.
* @readonly
*/
Object.defineProperty(Phaser.World.prototype, "centerX", {
@@ -218,8 +203,9 @@ Object.defineProperty(Phaser.World.prototype, "centerX", {
});
/**
* Get
* @returns {number} return the Y position of the center point of the world
* @name Phaser.World#centerY
* @property {number} centerY - Gets the Y position corresponding to the center point of the world.
* @readonly
*/
Object.defineProperty(Phaser.World.prototype, "centerY", {
@@ -230,8 +216,9 @@ Object.defineProperty(Phaser.World.prototype, "centerY", {
});
/**
* Get
* @returns {number} a random integer which is lesser or equal to the current width of the game world
* @name Phaser.World#randomX
* @property {number} randomX - Gets a random integer which is lesser than or equal to the current width of the game world.
* @readonly
*/
Object.defineProperty(Phaser.World.prototype, "randomX", {
@@ -242,8 +229,9 @@ Object.defineProperty(Phaser.World.prototype, "randomX", {
});
/**
* Get
* @returns {number} a random integer which is lesser or equal to the current height of the game world
* @name Phaser.World#randomY
* @property {number} randomY - Gets a random integer which is lesser than or equal to the current height of the game world.
* @readonly
*/
Object.defineProperty(Phaser.World.prototype, "randomY", {