Fixed up the namespace in the documentation and finished off all sections other than Game Objects and Physics (yuck).

This commit is contained in:
Richard Davey
2013-10-03 02:38:35 +01:00
parent f832bacfd6
commit 96da57cac0
156 changed files with 65938 additions and 2035 deletions
+58 -27
View File
@@ -2,23 +2,19 @@
* @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.Colors
*/
/**
* A collection of methods useful for manipulating and comparing colors.
*
* @class Phaser.Color
*/
Phaser.Color = {
/**
* Given an alpha and 3 color values this will return an integer representation of it.
*
* @method getColor32
* @method Phaser.Color.getColor32
* @param {number} alpha - The Alpha value (between 0 and 255).
* @param {number} red - The Red channel value (between 0 and 255).
* @param {number} green - The Green channel value (between 0 and 255).
@@ -32,7 +28,7 @@ Phaser.Color = {
/**
* Given 3 color values this will return an integer representation of it.
*
* @method getColor
* @method Phaser.Color.getColor
* @param {number} red - The Red channel value (between 0 and 255).
* @param {number} green - The Green channel value (between 0 and 255).
* @param {number} blue - The Blue channel value (between 0 and 255).
@@ -45,8 +41,8 @@ Phaser.Color = {
/**
* Converts the given hex string into an object containing the RGB values.
*
* @method hexToRGB
* @param {string}h - The string hex color to convert.
* @method Phaser.Color.hexToRGB
* @param {string} h - The string hex color to convert.
* @returns {object} An object with 3 properties: r,g and b.
*/
hexToRGB: function (h) {
@@ -64,64 +60,78 @@ Phaser.Color = {
* Returns a string containing handy information about the given color including string hex value,
* RGB format information and HSL information. Each section starts on a newline, 3 lines in total.
*
* @method getColorInfo
* @method Phaser.Color.getColorInfo
* @param {number} color - A color value in the format 0xAARRGGBB.
* @returns {string}String containing the 3 lines of information.
* @returns {string} String containing the 3 lines of information.
*/
getColorInfo: function (color) {
var argb = Phaser.Color.getRGB(color);
var hsl = Phaser.Color.RGBtoHSV(color);
// Hex format
var result = Phaser.Color.RGBtoHexstring(color) + "\n";
// RGB format
result = result.concat("Alpha: " + argb.alpha + " Red: " + argb.red + " Green: " + argb.green + " Blue: " + argb.blue) + "\n";
// HSL info
result = result.concat("Hue: " + hsl.hue + " Saturation: " + hsl.saturation + " Lightnes: " + hsl.lightness);
return result;
},
/**
* Return a string representation of the color in the format 0xAARRGGBB.
*
* @method RGBtoHexstring
* @method Phaser.Color.RGBtoHexstring
* @param {number} color - The color to get the string representation for
* @returns {String A string of length 10 characters in the format 0xAARRGGBB
* @returns {string} A string of length 10 characters in the format 0xAARRGGBB
*/
RGBtoHexstring: function (color) {
var argb = Phaser.Color.getRGB(color);
return "0x" + Phaser.Color.colorToHexstring(argb.alpha) + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue);
},
/**
* Return a string representation of the color in the format #RRGGBB.
*
* @method RGBtoWebstring
* @method Phaser.Color.RGBtoWebstring
* @param {number} color - The color to get the string representation for.
* @returns {string}A string of length 10 characters in the format 0xAARRGGBB.
* @returns {string} A string of length 10 characters in the format 0xAARRGGBB.
*/
RGBtoWebstring: function (color) {
var argb = Phaser.Color.getRGB(color);
return "#" + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue);
},
/**
* Return a string containing a hex representation of the given color.
*
* @method colorToHexstring
* @method Phaser.Color.colorToHexstring
* @param {number} color - The color channel to get the hex value for, must be a value between 0 and 255).
* @returns {string}A string of length 2 characters, i.e. 255 = FF, 0 = 00.
* @returns {string} A string of length 2 characters, i.e. 255 = FF, 0 = 00.
*/
colorToHexstring: function (color) {
var digits = "0123456789ABCDEF";
var lsd = color % 16;
var msd = (color - lsd) / 16;
var hexified = digits.charAt(msd) + digits.charAt(lsd);
return hexified;
},
/**
* Interpolates the two given colours based on the supplied step and currentStep properties.
* @method interpolateColor
* @method Phaser.Color.interpolateColor
* @param {number} color1 - Description.
* @param {number} color2 - Description.
* @param {number} steps - Description.
@@ -130,18 +140,22 @@ Phaser.Color = {
* @returns {number} The interpolated color value.
*/
interpolateColor: function (color1, color2, steps, currentStep, alpha) {
if (typeof alpha === "undefined") { alpha = 255; }
var src1 = Phaser.Color.getRGB(color1);
var src2 = Phaser.Color.getRGB(color2);
var r = (((src2.red - src1.red) * currentStep) / steps) + src1.red;
var g = (((src2.green - src1.green) * currentStep) / steps) + src1.green;
var b = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue;
return Phaser.Color.getColor32(alpha, r, g, b);
},
/**
* Interpolates the two given colours based on the supplied step and currentStep properties.
* @method interpolateColorWithRGB
* @method Phaser.Color.interpolateColorWithRGB
* @param {number} color - Description.
* @param {number} r - Description.
* @param {number} g - Description.
@@ -151,16 +165,19 @@ Phaser.Color = {
* @returns {number} The interpolated color value.
*/
interpolateColorWithRGB: function (color, r, g, b, steps, currentStep) {
var src = Phaser.Color.getRGB(color);
var or = (((r - src.red) * currentStep) / steps) + src.red;
var og = (((g - src.green) * currentStep) / steps) + src.green;
var ob = (((b - src.blue) * currentStep) / steps) + src.blue;
return Phaser.Color.getColor(or, og, ob);
},
/**
* Interpolates the two given colours based on the supplied step and currentStep properties.
* @method interpolateRGB
* @method Phaser.Color.interpolateRGB
* @param {number} r1 - Description.
* @param {number} g1 - Description.
* @param {number} b1 - Description.
@@ -172,10 +189,13 @@ Phaser.Color = {
* @returns {number} The interpolated color value.
*/
interpolateRGB: function (r1, g1, b1, r2, g2, b2, steps, currentStep) {
var r = (((r2 - r1) * currentStep) / steps) + r1;
var g = (((g2 - g1) * currentStep) / steps) + g1;
var b = (((b2 - b1) * currentStep) / steps) + b1;
return Phaser.Color.getColor(r, g, b);
},
/**
@@ -183,27 +203,33 @@ Phaser.Color = {
* <p>Set the min value to start each channel from the given offset.</p>
* <p>Set the max value to restrict the maximum color used per channel</p>
*
* @method getRandomColor
* @method Phaser.Color.getRandomColor
* @param {number} min - The lowest value to use for the color.
* @param {number} max - The highest value to use for the color.
* @param {number} alpha - The alpha value of the returning color (default 255 = fully opaque).
* @returns {number} 32-bit color value with alpha.
*/
getRandomColor: function (min, max, alpha) {
if (typeof min === "undefined") { min = 0; }
if (typeof max === "undefined") { max = 255; }
if (typeof alpha === "undefined") { alpha = 255; }
// Sanity checks
if (max > 255) {
return Phaser.Color.getColor(255, 255, 255);
}
if (min > max) {
return Phaser.Color.getColor(255, 255, 255);
}
var red = min + Math.round(Math.random() * (max - min));
var green = min + Math.round(Math.random() * (max - min));
var blue = min + Math.round(Math.random() * (max - min));
return Phaser.Color.getColor32(alpha, red, green, blue);
},
/**
@@ -211,37 +237,42 @@ Phaser.Color = {
*
* <p>Alpha will only be set if it exist in the given color (0xAARRGGBB)</p>
*
* @method getRGB
* @method Phaser.Color.getRGB
* @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB).
* @returns {object} An Object with properties: alpha, red, green, blue.
*/
getRGB: function (color) {
return {
alpha: color >>> 24,
red: color >> 16 & 0xFF,
green: color >> 8 & 0xFF,
blue: color & 0xFF
};
},
/**
* Returns a CSS friendly string value from the given color.
* @method getWebRGB
* @method Phaser.Color.getWebRGB
* @param {number} color
* @returns {string}A string in the format: 'rgba(r,g,b,a)'
*/
getWebRGB: function (color) {
var alpha = (color >>> 24) / 255;
var red = color >> 16 & 0xFF;
var green = color >> 8 & 0xFF;
var blue = color & 0xFF;
return 'rgba(' + red.toString() + ',' + green.toString() + ',' + blue.toString() + ',' + alpha.toString() + ')';
},
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255.
*
* @method getAlpha
* @method Phaser.Color.getAlpha
* @param {number} color - In the format 0xAARRGGBB.
* @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).
*/
@@ -252,7 +283,7 @@ Phaser.Color = {
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1.
*
* @method getAlphaFloat
* @method Phaser.Color.getAlphaFloat
* @param {number} color - In the format 0xAARRGGBB.
* @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).
*/
@@ -263,7 +294,7 @@ Phaser.Color = {
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255.
*
* @method getRed
* @method Phaser.Color.getRed
* @param {number} color In the format 0xAARRGGBB.
* @returns {number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red).
*/
@@ -274,7 +305,7 @@ Phaser.Color = {
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255.
*
* @method getGreen
* @method Phaser.Color.getGreen
* @param {number} color - In the format 0xAARRGGBB.
* @returns {number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green).
*/
@@ -285,7 +316,7 @@ Phaser.Color = {
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255.
*
* @method getBlue
* @method Phaser.Color.getBlue
* @param {number} color - In the format 0xAARRGGBB.
* @returns {number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue).
*/
+107 -93
View File
@@ -2,11 +2,11 @@
* @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.Debug
*/
/**
* A collection of methods for displaying debug information about game objects.
* A collection of methods for displaying debug information about game objects. Phaser.Debug requires a CANVAS game type in order to render, so if you've got
* your game set to use Phaser.AUTO then swap it for Phaser.CANVAS to ensure WebGL doesn't kick in, then the Debug functions will all display.
*
* @class Phaser.Utils.Debug
* @constructor
@@ -20,40 +20,40 @@ Phaser.Utils.Debug = function (game) {
this.game = game;
/**
* @property {Context} context - Description.
* @property {Context} context - The canvas context on which to render the debug information.
*/
this.context = game.context;
/**
* @property {string} font - Description.
* @property {string} font - The font that the debug information is rendered in.
* @default '14px Courier'
*/
this.font = '14px Courier';
/**
* @property {number} lineHeight - Description.
* @property {number} lineHeight - The line height between the debug text.
*/
this.lineHeight = 16;
/**
* @property {boolean} renderShadow - Description.
* @property {boolean} renderShadow - Should the text be rendered with a slight shadow? Makes it easier to read on different types of background.
*/
this.renderShadow = true;
/**
* @property {Context} currentX - Description.
* @property {Context} currentX - The current X position the debug information will be rendered at.
* @default
*/
this.currentX = 0;
/**
* @property {number} currentY - Description.
* @property {number} currentY - The current Y position the debug information will be rendered at.
* @default
*/
this.currentY = 0;
/**
* @property {number} currentAlpha - Description.
* @property {number} currentAlpha - The current alpha the debug information will be rendered at.
* @default
*/
this.currentAlpha = 1;
@@ -63,8 +63,8 @@ Phaser.Utils.Debug = function (game) {
Phaser.Utils.Debug.prototype = {
/**
* Internal method that resets the debug output values.
* @method start
* Internal method that resets and starts the debug output values.
* @method Phaser.Utils.Debug#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.
@@ -97,6 +97,10 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Internal method that stops the debug output.
* @method Phaser.Utils.Debug#stop
*/
stop: function () {
this.context.restore();
@@ -106,7 +110,7 @@ Phaser.Utils.Debug.prototype = {
/**
* Internal method that outputs a single line of text.
* @method line
* @method Phaser.Utils.Debug#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.
@@ -142,11 +146,11 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderQuadTree
* @param {Description} quadtree - Description.
* @param {string} color - Description.
*/
* Visually renders a QuadTree to the display.
* @method Phaser.Utils.Debug#renderQuadTree
* @param {Phaser.QuadTree} quadtree - The quadtree to render.
* @param {string} color - The color of the lines in the quadtree.
*/
renderQuadTree: function (quadtree, color) {
color = color || 'rgba(255,0,0,0.3)';
@@ -182,12 +186,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderSpriteCorners
* Renders the corners and point information of the given Sprite.
* @method Phaser.Utils.Debug#renderSpriteCorners
* @param {Phaser.Sprite} sprite - The sprite to be rendered.
* @param {boolean} showText - Description.
* @param {boolean} showBounds - Description.
* @param {string} color - Description.
* @param {boolean} [showText=false] - If true the x/y coordinates of each point will be rendered.
* @param {boolean} [showBounds=false] - If true the bounds will be rendered over the top of the sprite.
* @param {string} [color='rgb(255,0,255)'] - The color the text is rendered in.
*/
renderSpriteCorners: function (sprite, showText, showBounds, color) {
@@ -238,12 +242,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render debug infos (including id, position, rotation, scrolling factor, worldBounds and some other properties).
* @method renderSoundInfo
* @param {Description} sound - Description.
* Render Sound information, including decoded state, duration, volume and more.
* @method Phaser.Utils.Debug#renderSoundInfo
* @param {Phaser.Sound} sound - The sound object to debug.
* @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} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderSoundInfo: function (sound, x, y, color) {
@@ -275,12 +279,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render debug infos. (including id, position, rotation, scrolling factor, worldBounds and some other properties)
* @method renderCameraInfo
* @param {Description} camera - Description.
* Render camera information including dimensions and location.
* @method Phaser.Utils.Debug#renderCameraInfo
* @param {Phaser.Camera} 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)
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderCameraInfo: function (camera, x, y, color) {
@@ -289,7 +293,7 @@ Phaser.Utils.Debug.prototype = {
return;
}
color = color || 'rgb(255,255,0)';
color = color || 'rgb(255,255,255)';
this.start(x, y, color);
this.line('Camera (' + camera.width + ' x ' + camera.height + ')');
@@ -299,13 +303,13 @@ 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 {boolean} hideIfUp - Description.
* @param {string} downColor - Description.
* @param {string} upColor - Description.
* @param {string} color - Description.
* Renders the Pointer.circle object onto the stage in green if down or red if up along with debug text.
* @method Phaser.Utils.Debug#renderDebug
* @param {Phaser.Pointer} pointer - Description.
* @param {boolean} [hideIfUp=false] - Doesn't render the circle if the pointer is up.
* @param {string} [downColor='rgba(0,255,0,0.5)'] - The color the circle is rendered in if down.
* @param {string} [upColor='rgba(255,0,0,0.5)'] - The color the circle is rendered in if up (and hideIfUp is false).
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderPointer: function (pointer, hideIfUp, downColor, upColor, color) {
@@ -314,7 +318,7 @@ Phaser.Utils.Debug.prototype = {
return;
}
hideIfUp = hideIfUp || false;
if (typeof hideIfUp === 'undefined') { hideIfUp = false; }
downColor = downColor || 'rgba(0,255,0,0.5)';
upColor = upColor || 'rgba(255,0,0,0.5)';
color = color || 'rgb(255,255,255)';
@@ -360,11 +364,11 @@ Phaser.Utils.Debug.prototype = {
/**
* Render Sprite Input Debug information.
* @method renderSpriteInputInfo
* @method Phaser.Utils.Debug#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).
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderSpriteInputInfo: function (sprite, x, y, color) {
@@ -382,11 +386,11 @@ Phaser.Utils.Debug.prototype = {
/**
* Render Sprite collision.
* @method renderSpriteCollision
* @method Phaser.Utils.Debug#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).
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderSpriteCollision: function (sprite, x, y, color) {
@@ -406,10 +410,10 @@ Phaser.Utils.Debug.prototype = {
/**
* Render debug information about the Input object.
* @method renderInputInfo
* @method Phaser.Utils.Debug#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)
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderInputInfo: function (x, y, color) {
@@ -431,12 +435,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render debug infos (including name, bounds info, position and some other properties).
* @method renderSpriteInfo
* Render debug infos (including name, bounds info, position and some other properties) about the Sprite.
* @method Phaser.Utils.Debug#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).
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderSpriteInfo: function (sprite, x, y, color) {
@@ -480,12 +484,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Render debug infos (including name, bounds info, position and some other properties).
* @method renderWorldTransformInfo
* Render the World Transform information of the given Sprite.
* @method Phaser.Utils.Debug#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).
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderWorldTransformInfo: function (sprite, x, y, color) {
@@ -509,12 +513,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderLocalTransformInfo
* Render the Local Transform information of the given Sprite.
* @method Phaser.Utils.Debug#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).
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderLocalTransformInfo: function (sprite, x, y, color) {
@@ -540,12 +544,12 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderPointInfo
* @param {Phaser.Sprite} sprite - Description.
* Renders Point coordinates in the given color.
* @method Phaser.Utils.Debug#renderPointInfo
* @param {Phaser.Point} 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).
* @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
*/
renderPointInfo: function (point, x, y, color) {
@@ -563,8 +567,8 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderSpriteBounds
* Renders just the Sprite.body bounds.
* @method Phaser.Utils.Debug#renderSpriteBody
* @param {Phaser.Sprite} sprite - Description.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
@@ -587,6 +591,13 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Renders just the full Sprite bounds.
* @method Phaser.Utils.Debug#renderSpriteBounds
* @param {Phaser.Sprite} sprite - Description.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
* @param {boolean} [fill=false] - If false the bounds outline is rendered, if true the whole rectangle is rendered.
*/
renderSpriteBounds: function (sprite, color, fill) {
if (this.context == null)
@@ -596,6 +607,8 @@ Phaser.Utils.Debug.prototype = {
color = color || 'rgb(255,0,255)';
if (typeof fill === 'undefined') { fill = false; }
this.start(0, 0, color);
if (fill)
@@ -615,90 +628,90 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* @method renderPixel
* Renders a single pixel.
* @method Phaser.Utils.Debug#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.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderPixel: function (x, y, fillStyle) {
renderPixel: function (x, y, color) {
if (this.context == null)
{
return;
}
fillStyle = fillStyle || 'rgba(0,255,0,1)';
color = color || 'rgba(0,255,0,1)';
this.start();
this.context.fillStyle = fillStyle;
this.context.fillStyle = color;
this.context.fillRect(x, y, 2, 2);
this.stop();
},
/**
* Description.
* @method renderPoint
* @param {Description} point - Description.
* @param {string} fillStyle - Description.
*/
renderPoint: function (point, fillStyle) {
* Renders a Point object.
* @method Phaser.Utils.Debug#renderPoint
* @param {Phaser.Point} point - The Point to render.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderPoint: function (point, color) {
if (this.context == null)
{
return;
}
fillStyle = fillStyle || 'rgba(0,255,0,1)';
color = color || 'rgba(0,255,0,1)';
this.start();
this.context.fillStyle = fillStyle;
this.context.fillStyle = color;
this.context.fillRect(point.x, point.y, 4, 4);
this.stop();
},
/**
* Description.
* @method renderRectangle
* @param {Description} rect - Description.
* @param {string} fillStyle - Description.
* Renders a Rectangle.
* @method Phaser.Utils.Debug#renderRectangle
* @param {Phaser.Rectangle} rect - The Rectangle to render.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderRectangle: function (rect, fillStyle) {
renderRectangle: function (rect, color) {
if (this.context == null)
{
return;
}
fillStyle = fillStyle || 'rgba(0,255,0,0.3)';
color = color || 'rgba(0,255,0,0.3)';
this.start();
this.context.fillStyle = fillStyle;
this.context.fillStyle = color;
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
this.stop();
},
/**
* Description.
* @method renderCircle
* @param {Description} circle - Description.
* @param {string} fillStyle - Description.
*/
renderCircle: function (circle, fillStyle) {
* Renders a Circle.
* @method Phaser.Utils.Debug#renderCircle
* @param {Phaser.Circle} circle - The Circle to render.
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
*/
renderCircle: function (circle, color) {
if (this.context == null)
{
return;
}
fillStyle = fillStyle || 'rgba(0,255,0,0.3)';
color = color || 'rgba(0,255,0,0.3)';
this.start();
this.context.beginPath();
this.context.fillStyle = fillStyle;
this.context.fillStyle = color;
this.context.arc(circle.x, circle.y, circle.radius, 0, Math.PI * 2, false);
this.context.fill();
this.context.closePath();
@@ -708,9 +721,9 @@ Phaser.Utils.Debug.prototype = {
/**
* Render text.
* @method renderText
* @method Phaser.Utils.Debug#renderText
* @param {string} text - The line of text to draw.
* @param{number} x - X position of the debug info 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).
* @param {string} font - The font of text to draw.
@@ -734,9 +747,10 @@ Phaser.Utils.Debug.prototype = {
},
/**
* Description.
* Dumps the Linked List to the console.
*
* @method Phaser.LinkedList#dump
* @method Phaser.Utils.Debug#Phaser.LinkedList#dump
* @param {Phaser.LinkedList} list - The LinkedList to dump.
*/
dumpLinkedList: function (list) {
+11 -16
View File
@@ -2,27 +2,25 @@
* @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.Utils
*/
/**
*
* @class Utils
* @class Phaser.Utils
* @static
*/
Phaser.Utils = {
/**
* Javascript string pad ({@link http://www.webtoolkit.info/})
* Javascript string pad http://www.webtoolkit.info/.
* pad = the string to pad it out with (defaults to a space)<br>
* dir = 1 (left), 2 (right), 3 (both)
* @method pad
* @method Phaser.Utils.pad
* @param {string} str - The target string.
* @param {number} len - Description.
* @param {number} pad - the string to pad it out with (defaults to a space).
* @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both).
* @return {string}
**/
*/
pad: function (str, len, pad, dir) {
if (typeof(len) == "undefined") { var len = 0; }
@@ -54,10 +52,10 @@ Phaser.Utils = {
},
/**
* This is a slightly modified version of jQuery.isPlainObject.
* @method isPlainObject
* @param {object} obj - Description.
* @return {boolean} - Description.
* This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object].
* @method Phaser.Utils.isPlainObject
* @param {object} obj - The object to inspect.
* @return {boolean} - true if the object is plain, otherwise false.
*/
isPlainObject: function (obj) {
@@ -96,9 +94,9 @@ Phaser.Utils = {
// objects ... (objects to recurse and copy from)
/**
* This is a slightly modified version of {@link http://api.jquery.com/jQuery.extend/|jQuery.extend}
* @method extend
* @return {Description} Description.
* This is a slightly modified version of http://api.jquery.com/jQuery.extend/
* @method Phaser.Utils.extend
* @return {object} The extended object.
*/
extend: function () {
@@ -178,7 +176,6 @@ Phaser.Utils = {
/**
* Converts a hex color number to an [R, G, B] array
*
* @method HEXtoRGB
* @param {number} hex
* @return {array}
*/
@@ -188,8 +185,6 @@ function HEXtoRGB(hex) {
/**
* A polyfill for Function.prototype.bind
*
* @method bind
*/
if (typeof Function.prototype.bind != 'function') {
Function.prototype.bind = (function () {