Adding docs.

This commit is contained in:
Richard Davey
2013-10-01 13:54:29 +01:00
parent fa15f8015d
commit 305b12d76b
64 changed files with 6268 additions and 2682 deletions
+163 -33
View File
@@ -1,38 +1,73 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @module Phaser
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.Debug
*/
/**
* A collection of methods for displaying debug information about game objects.
*
* @class DebugUtils
* @class Phaser.Utils.Debug
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
*/
Phaser.Utils.Debug = function (game) {
/**
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = game;
/**
* @property {Context} context - Description.
*/
this.context = game.context;
/**
* @property {string} font - Description.
* @default '14px Courier'
*/
this.font = '14px Courier';
/**
* @property {number} lineHeight - Description.
*/
this.lineHeight = 16;
/**
* @property {bool} renderShadow - Description.
*/
this.renderShadow = true;
/**
* @property {Context} currentX - Description.
* @default
*/
this.currentX = 0;
/**
* @property {number} currentY - Description.
* @default
*/
this.currentY = 0;
/**
* @property {number} currentAlpha - Description.
* @default
*/
this.currentAlpha = 1;
};
Phaser.Utils.Debug.prototype = {
/**
* Internal method that resets the debug output values.
* @method start
* @param {Number} x The X value the debug info will start from.
* @param {Number} y The Y value the debug info will start from.
* @param {String} color The color the debug info will drawn in.
* @param {number} x - The X value the debug info will start from.
* @param {number} y - The Y value the debug info will start from.
* @param {string} color - The color the debug info will drawn in.
*/
start: function (x, y, color) {
@@ -72,9 +107,9 @@ Phaser.Utils.Debug.prototype = {
/**
* Internal method that outputs a single line of text.
* @method line
* @param {String} text The line of text to draw.
* @param {Number} x The X value the debug info will start from.
* @param {Number} y The Y value the debug info will start from.
* @param {string} text - The line of text to draw.
* @param {number} x - The X value the debug info will start from.
* @param {number} y - The Y value the debug info will start from.
*/
line: function (text, x, y) {
@@ -106,6 +141,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderQuadTree
* @param {Description} quadtree - Description.
* @param {string} color - Description.
*/
renderQuadTree: function (quadtree, color) {
color = color || 'rgba(255,0,0,0.3)';
@@ -140,6 +181,14 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderSpriteCorners
* @param {Phaser.Sprite} sprite - The sprite to be rendered.
* @param {bool} showText - Description.
* @param {bool} showBounds - Description.
* @param {string} color - Description.
*/
renderSpriteCorners: function (sprite, showText, showBounds, color) {
if (this.context == null)
@@ -189,10 +238,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render debug infos. (including id, position, rotation, scrolling factor, worldBounds and some other properties)
* @param x {number} X position of the debug info to be rendered.
* @param y {number} Y position of the debug info to be rendered.
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
* Render debug infos (including id, position, rotation, scrolling factor, worldBounds and some other properties).
* @method renderSoundInfo
* @param {Description} sound - Description.
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - color of the debug info to be rendered. (format is css color string).
*/
renderSoundInfo: function (sound, x, y, color) {
@@ -225,9 +276,11 @@ Phaser.Utils.Debug.prototype = {
/**
* Render debug infos. (including id, position, rotation, scrolling factor, worldBounds and some other properties)
* @param x {number} X position of the debug info to be rendered.
* @param y {number} Y position of the debug info to be rendered.
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
* @method renderCameraInfo
* @param {Description} camera - Description.
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - color of the debug info to be rendered (format is css color string)
*/
renderCameraInfo: function (camera, x, y, color) {
@@ -248,6 +301,11 @@ Phaser.Utils.Debug.prototype = {
/**
* Renders the Pointer.circle object onto the stage in green if down or red if up.
* @method renderDebug
* @param {Description} pointer - Description.
* @param {bool} hideIfUp - Description.
* @param {string} downColor - Description.
* @param {string} upColor - Description.
* @param {string} color - Description.
*/
renderPointer: function (pointer, hideIfUp, downColor, upColor, color) {
@@ -301,10 +359,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render Sprite Input Debug information
* @param x {number} X position of the debug info to be rendered.
* @param y {number} Y position of the debug info to be rendered.
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
* Render Sprite Input Debug information.
* @method renderSpriteInputInfo
* @param {Phaser.Sprite} sprite - The sprite to be rendered.
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - color of the debug info to be rendered (format is css color string).
*/
renderSpriteInputInfo: function (sprite, x, y, color) {
@@ -320,6 +380,14 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render Sprite collision.
* @method renderSpriteCollision
* @param {Phaser.Sprite} sprite - The sprite to be rendered.
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - color of the debug info to be rendered (format is css color string).
*/
renderSpriteCollision: function (sprite, x, y, color) {
color = color || 'rgb(255,255,255)';
@@ -338,9 +406,10 @@ Phaser.Utils.Debug.prototype = {
/**
* Render debug information about the Input object.
* @param x {number} X position of the debug info to be rendered.
* @param y {number} Y position of the debug info to be rendered.
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
* @method renderInputInfo
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - color of the debug info to be rendered. (format is css color string)
*/
renderInputInfo: function (x, y, color) {
@@ -362,10 +431,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render debug infos. (including name, bounds info, position and some other properties)
* @param x {number} X position of the debug info to be rendered.
* @param y {number} Y position of the debug info to be rendered.
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
* Render debug infos (including name, bounds info, position and some other properties).
* @method renderSpriteInfo
* @param {Phaser.Sprite} sprite - Description.
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderSpriteInfo: function (sprite, x, y, color) {
@@ -391,6 +462,7 @@ Phaser.Utils.Debug.prototype = {
// 4 = scaleY
// 5 = translateY
// this.line('id: ' + sprite._id);
// this.line('scale x: ' + sprite.worldTransform[0]);
// this.line('scale y: ' + sprite.worldTransform[4]);
@@ -407,6 +479,14 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render debug infos (including name, bounds info, position and some other properties).
* @method renderWorldTransformInfo
* @param {Phaser.Sprite} sprite - Description.
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderWorldTransformInfo: function (sprite, x, y, color) {
if (this.context == null)
@@ -428,6 +508,14 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderLocalTransformInfo
* @param {Phaser.Sprite} sprite - Description.
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderLocalTransformInfo: function (sprite, x, y, color) {
if (this.context == null)
@@ -451,6 +539,14 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderPointInfo
* @param {Phaser.Sprite} sprite - Description.
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderPointInfo: function (point, x, y, color) {
if (this.context == null)
@@ -466,7 +562,13 @@ Phaser.Utils.Debug.prototype = {
},
renderSpriteBody: function (sprite, color) {
/**
* Description.
* @method renderSpriteBounds
* @param {Phaser.Sprite} sprite - Description.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderSpriteBounds: function (sprite, color) {
if (this.context == null)
{
@@ -512,6 +614,13 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderPixel
* @param {number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} fillStyle - Description.
*/
renderPixel: function (x, y, fillStyle) {
if (this.context == null)
@@ -528,6 +637,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderPoint
* @param {Description} point - Description.
* @param {string} fillStyle - Description.
*/
renderPoint: function (point, fillStyle) {
if (this.context == null)
@@ -544,6 +659,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderRectangle
* @param {Description} rect - Description.
* @param {string} fillStyle - Description.
*/
renderRectangle: function (rect, fillStyle) {
if (this.context == null)
@@ -560,6 +681,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderCircle
* @param {Description} circle - Description.
* @param {string} fillStyle - Description.
*/
renderCircle: function (circle, fillStyle) {
if (this.context == null)
@@ -580,10 +707,13 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render text
* @param x {number} X position of the debug info to be rendered.
* @param y {number} Y position of the debug info to be rendered.
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
* Render text.
* @method renderText
* @param {string} text - The line of text to draw.
* @param{number} x - X position of the debug info to be rendered.
* @param {number} y - Y position of the debug info to be rendered.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
* @param {string} font - The font of text to draw.
*/
renderText: function (text, x, y, color, font) {