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
+3 -2
View File
@@ -2,15 +2,16 @@
* @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.Intro
*/
/**
* @overview
*
* Phaser - http://www.phaser.io
*
* v{version} - Built at: {buildDate}
*
* @author Richard Davey http://www.photonstorm.com @photonstorm
* By Richard Davey http://www.photonstorm.com @photonstorm
*
* A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and
* constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm).
+2 -2
View File
@@ -5,8 +5,8 @@
*/
/**
* @module Phaser
*/
* @namespace Phaser
*/
var Phaser = Phaser || {
VERSION: '1.0.7-beta',
+2 -2
View File
@@ -13,7 +13,7 @@
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {Phaser.Sprite} parent - A reference to the owner of this Animation.
* @param {string} name - The unique name for this animation, used in playback commands.
* @param {Phaser.Animation.FrameData} frameData - The FrameData object that contains all frames used by this Animation.
* @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation.
* @param {(Array.<number>|Array.<string>)} frames - An array of numbers or strings indicating which frames to play in which order.
* @param {number} delay - The time between each frame of the animation, given in ms.
* @param {boolean} looped - Should this animation loop or play through once.
@@ -106,7 +106,7 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
this._frameSkip = 1;
/**
* @property {Phaser.Animation.Frame} currentFrame - The currently displayed frame of the Animation.
* @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation.
*/
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
+4 -4
View File
@@ -25,7 +25,7 @@ Phaser.AnimationManager = function (sprite) {
this.game = sprite.game;
/**
* @property {Phaser.Animation.Frame} currentFrame - The currently displayed Frame of animation, if any.
* @property {Phaser.Frame} currentFrame - The currently displayed Frame of animation, if any.
* @default
*/
this.currentFrame = null;
@@ -37,7 +37,7 @@ Phaser.AnimationManager = function (sprite) {
this.updateIfVisible = true;
/**
* @property {Phaser.Animation.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData.
* @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData.
* @private
* @default
*/
@@ -65,7 +65,7 @@ Phaser.AnimationManager.prototype = {
*
* @method Phaser.AnimationManager#loadFrameData
* @private
* @param {Phaser.Animation.FrameData} frameData - The FrameData set to load.
* @param {Phaser.FrameData} frameData - The FrameData set to load.
*/
loadFrameData: function (frameData) {
@@ -258,7 +258,7 @@ Phaser.AnimationManager.prototype = {
/**
* @name Phaser.AnimationManager#frameData
* @property {Phaser.Animation.FrameData} frameData - The current animations FrameData.
* @property {Phaser.FrameData} frameData - The current animations FrameData.
* @readonly
*/
Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
+12 -12
View File
@@ -20,7 +20,7 @@ Phaser.AnimationParser = {
* @param {number} frameWidth - The fixed width of each frame of the animation.
* @param {number} frameHeight - The fixed height of each frame of the animation.
* @param {number} [frameMax=-1] - The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames".
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
*/
spriteSheet: function (game, key, frameWidth, frameHeight, frameMax) {
@@ -62,7 +62,7 @@ Phaser.AnimationParser = {
}
// Let's create some frames then
var data = new Phaser.Animation.FrameData();
var data = new Phaser.FrameData();
var x = 0;
var y = 0;
@@ -70,7 +70,7 @@ Phaser.AnimationParser = {
{
var uuid = game.rnd.uuid();
data.addFrame(new Phaser.Animation.Frame(i, x, y, frameWidth, frameHeight, '', uuid));
data.addFrame(new Phaser.Frame(i, x, y, frameWidth, frameHeight, '', uuid));
PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[key], {
x: x,
@@ -99,7 +99,7 @@ Phaser.AnimationParser = {
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {Object} json - The JSON data from the Texture Atlas. Must be in Array format.
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
*/
JSONData: function (game, json, cacheKey) {
@@ -112,7 +112,7 @@ Phaser.AnimationParser = {
}
// Let's create some frames then
var data = new Phaser.Animation.FrameData();
var data = new Phaser.FrameData();
// By this stage frames is a fully parsed array
var frames = json['frames'];
@@ -122,7 +122,7 @@ Phaser.AnimationParser = {
{
var uuid = game.rnd.uuid();
newFrame = data.addFrame(new Phaser.Animation.Frame(
newFrame = data.addFrame(new Phaser.Frame(
i,
frames[i].frame.x,
frames[i].frame.y,
@@ -170,7 +170,7 @@ Phaser.AnimationParser = {
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {Object} json - The JSON data from the Texture Atlas. Must be in JSON Hash format.
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
*/
JSONDataHash: function (game, json, cacheKey) {
@@ -183,7 +183,7 @@ Phaser.AnimationParser = {
}
// Let's create some frames then
var data = new Phaser.Animation.FrameData();
var data = new Phaser.FrameData();
// By this stage frames is a fully parsed array
var frames = json['frames'];
@@ -194,7 +194,7 @@ Phaser.AnimationParser = {
{
var uuid = game.rnd.uuid();
newFrame = data.addFrame(new Phaser.Animation.Frame(
newFrame = data.addFrame(new Phaser.Frame(
i,
frames[key].frame.x,
frames[key].frame.y,
@@ -244,7 +244,7 @@ Phaser.AnimationParser = {
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {Object} xml - The XML data from the Texture Atlas. Must be in Starling XML format.
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
*/
XMLData: function (game, xml, cacheKey) {
@@ -256,7 +256,7 @@ Phaser.AnimationParser = {
}
// Let's create some frames then
var data = new Phaser.Animation.FrameData();
var data = new Phaser.FrameData();
var frames = xml.getElementsByTagName('SubTexture');
var newFrame;
@@ -266,7 +266,7 @@ Phaser.AnimationParser = {
var frame = frames[i].attributes;
newFrame = data.addFrame(new Phaser.Animation.Frame(
newFrame = data.addFrame(new Phaser.Frame(
i,
frame.x.nodeValue,
frame.y.nodeValue,
+4 -4
View File
@@ -7,7 +7,7 @@
/**
* A Frame is a single frame of an animation and is part of a FrameData collection.
*
* @class Phaser.Animation.Frame
* @class Phaser.Frame
* @constructor
* @param {number} index - The index of this Frame within the FrameData set it is being added to.
* @param {number} x - X position of the frame within the texture image.
@@ -17,7 +17,7 @@
* @param {string} name - The name of the frame. In Texture Atlas data this is usually set to the filename.
* @param {string} uuid - Internal UUID key.
*/
Phaser.Animation.Frame = function (index, x, y, width, height, name, uuid) {
Phaser.Frame = function (index, x, y, width, height, name, uuid) {
/**
* @property {number} index - The index of this Frame within the FrameData set it is being added to.
@@ -123,12 +123,12 @@ Phaser.Animation.Frame = function (index, x, y, width, height, name, uuid) {
};
Phaser.Animation.Frame.prototype = {
Phaser.Frame.prototype = {
/**
* If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
*
* @method Phaser.Animation.Frame#setTrim
* @method Phaser.Frame#setTrim
* @param {boolean} trimmed - If this frame was trimmed or not.
* @param {number} actualWidth - The width of the frame before being trimmed.
* @param {number} actualHeight - The height of the frame before being trimmed.
+16 -16
View File
@@ -7,10 +7,10 @@
/**
* FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser.
*
* @class Phaser.Animation.FrameData
* @class Phaser.FrameData
* @constructor
*/
Phaser.Animation.FrameData = function () {
Phaser.FrameData = function () {
/**
* @property {Array} _frames - Local array of frames.
@@ -27,14 +27,14 @@ Phaser.Animation.FrameData = function () {
};
Phaser.Animation.FrameData.prototype = {
Phaser.FrameData.prototype = {
/**
* Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly.
*
* @method Phaser.Animation.FrameData#addFrame
* @param {Phaser.Animation.Frame} frame - The frame to add to this FrameData set.
* @return {Phaser.Animation.Frame} The frame that was just added.
* @method Phaser.FrameData#addFrame
* @param {Phaser.Frame} frame - The frame to add to this FrameData set.
* @return {Phaser.Frame} The frame that was just added.
*/
addFrame: function (frame) {
@@ -54,9 +54,9 @@ Phaser.Animation.FrameData.prototype = {
/**
* Get a Frame by its numerical index.
*
* @method Phaser.Animation.FrameData#getFrame
* @method Phaser.FrameData#getFrame
* @param {number} index - The index of the frame you want to get.
* @return {Phaser.Animation.Frame} The frame, if found.
* @return {Phaser.Frame} The frame, if found.
*/
getFrame: function (index) {
@@ -72,9 +72,9 @@ Phaser.Animation.FrameData.prototype = {
/**
* Get a Frame by its frame name.
*
* @method Phaser.Animation.FrameData#getFrameByName
* @method Phaser.FrameData#getFrameByName
* @param {string} name - The name of the frame you want to get.
* @return {Phaser.Animation.Frame} The frame, if found.
* @return {Phaser.Frame} The frame, if found.
*/
getFrameByName: function (name) {
@@ -90,7 +90,7 @@ Phaser.Animation.FrameData.prototype = {
/**
* Check if there is a Frame with the given name.
*
* @method Phaser.Animation.FrameData#checkFrameName
* @method Phaser.FrameData#checkFrameName
* @param {string} name - The name of the frame you want to check.
* @return {boolean} True if the frame is found, otherwise false.
*/
@@ -108,7 +108,7 @@ Phaser.Animation.FrameData.prototype = {
/**
* Returns a range of frames based on the given start and end frame indexes and returns them in an Array.
*
* @method Phaser.Animation.FrameData#getFrameRange
* @method Phaser.FrameData#getFrameRange
* @param {number} start - The starting frame index.
* @param {number} end - The ending frame index.
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
@@ -131,7 +131,7 @@ Phaser.Animation.FrameData.prototype = {
* Returns all of the Frames in this FrameData set where the frame index is found in the input array.
* The frames are returned in the output array, or if none is provided in a new Array object.
*
* @method Phaser.Animation.FrameData#getFrames
* @method Phaser.FrameData#getFrames
* @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
@@ -178,7 +178,7 @@ Phaser.Animation.FrameData.prototype = {
* Returns all of the Frame indexes in this FrameData set.
* The frames indexes are returned in the output array, or if none is provided in a new Array object.
*
* @method Phaser.Animation.FrameData#getFrameIndexes
* @method Phaser.FrameData#getFrameIndexes
* @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
@@ -221,11 +221,11 @@ Phaser.Animation.FrameData.prototype = {
};
/**
* @name Phaser.Animation.FrameData#total
* @name Phaser.FrameData#total
* @property {number} total - The total number of frames in this FrameData set.
* @readonly
*/
Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", {
Object.defineProperty(Phaser.FrameData.prototype, "total", {
get: function () {
return this._frames.length;
+9 -9
View File
@@ -90,7 +90,7 @@ Phaser.Cache.prototype = {
*/
addRenderTexture: function (key, texture) {
var frame = new Phaser.Animation.Frame(0, 0, 0, texture.width, texture.height, '', '');
var frame = new Phaser.Frame(0, 0, 0, texture.width, texture.height, '', '');
this._textures[key] = { texture: texture, frame: frame };
@@ -185,7 +185,7 @@ Phaser.Cache.prototype = {
PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
Phaser.Loader.Parser.bitmapFont(this.game, xmlData, key);
Phaser.LoaderParser.bitmapFont(this.game, xmlData, key);
// this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, xmlData, key);
},
@@ -198,7 +198,7 @@ Phaser.Cache.prototype = {
addDefaultImage: function () {
this._images['__default'] = { url: null, data: null, spriteSheet: false };
this._images['__default'].frame = new Phaser.Animation.Frame(0, 0, 0, 32, 32, '', '');
this._images['__default'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', '');
var base = new PIXI.BaseTexture();
base.width = 32;
@@ -221,7 +221,7 @@ Phaser.Cache.prototype = {
addImage: function (key, url, data) {
this._images[key] = { url: url, data: data, spriteSheet: false };
this._images[key].frame = new Phaser.Animation.Frame(0, 0, 0, data.width, data.height, '', '');
this._images[key].frame = new Phaser.Frame(0, 0, 0, data.width, data.height, '', '');
PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
@@ -411,7 +411,7 @@ Phaser.Cache.prototype = {
*
* @method Phaser.Cache#getFrameData
* @param {string} key - Asset key of the frame data you want.
* @return {Phaser.Animation.FrameData} The frame data you want.
* @return {Phaser.FrameData} The frame data you want.
*/
getFrameData: function (key) {
@@ -428,7 +428,7 @@ Phaser.Cache.prototype = {
*
* @method Phaser.Cache#getFrameByIndex
* @param {string} key - Asset key of the frame data you want.
* @return {Phaser.Animation.Frame} The frame data you want.
* @return {Phaser.Frame} The frame data you want.
*/
getFrameByIndex: function (key, frame) {
@@ -445,7 +445,7 @@ Phaser.Cache.prototype = {
*
* @method Phaser.Cache#getFrameByName
* @param {string} key - Asset key of the frame data you want.
* @return {Phaser.Animation.Frame} The frame data you want.
* @return {Phaser.Frame} The frame data you want.
*/
getFrameByName: function (key, frame) {
@@ -462,7 +462,7 @@ Phaser.Cache.prototype = {
*
* @method Phaser.Cache#getFrame
* @param {string} key - Asset key of the frame data you want.
* @return {Phaser.Animation.Frame} The frame data you want.
* @return {Phaser.Frame} The frame data you want.
*/
getFrame: function (key) {
@@ -479,7 +479,7 @@ Phaser.Cache.prototype = {
*
* @method Phaser.Cache#getTextureFrame
* @param {string} key - Asset key of the frame data you want.
* @return {Phaser.Animation.Frame} The frame data you want.
* @return {Phaser.Frame} The frame data you want.
*/
getTextureFrame: function (key) {
@@ -5,15 +5,15 @@
*/
/**
* Phaser.Loader.Parser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache.
* Phaser.LoaderParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache.
*
* @class Phaser.Loader.Parser
* @class Phaser.LoaderParser
*/
Phaser.Loader.Parser = {
Phaser.LoaderParser = {
/**
* Parse frame data from an XML file.
* @method Phaser.Loader.Parser.bitmapFont
* @method Phaser.LoaderParser.bitmapFont
* @param {object} xml - XML data you want to parse.
* @return {FrameData} Generated FrameData object.
*/
@@ -22,7 +22,7 @@ Phaser.Loader.Parser = {
// Malformed?
if (!xml.getElementsByTagName('font'))
{
console.warn("Phaser.Loader.Parser.bitmapFont: Invalid XML given, missing <font> tag");
console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing <font> tag");
return;
}
-1
View File
@@ -19,7 +19,6 @@
*/
/**
* @overview
* @copyright © 2012 Timo Hausmann
*
* Permission is hereby granted, free of charge, to any person obtaining
+9 -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.Time
*/
/**
* Time constructor.
*
* @class Phaser.Time
* @classdesc This is the core internal game clock. It manages the elapsed time and calculation of elapsed values,
* used for game object motion and tweens.
* @classdesc This is the core internal game clock. It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens.
* @constructor
* @param {Phaser.Game} game A reference to the currently running game.
*/
@@ -160,7 +158,7 @@ Phaser.Time.prototype = {
/**
* The number of seconds that have elapsed since the game was started.
* @method totalElapsedSeconds
* @method Phaser.Time#totalElapsedSeconds
* @return {number}
*/
totalElapsedSeconds: function() {
@@ -168,9 +166,8 @@ Phaser.Time.prototype = {
},
/**
* Updates the game clock and calculate the fps.
* This is called automatically by Phaser.Game.
* @method update
* Updates the game clock and calculate the fps. This is called automatically by Phaser.Game.
* @method Phaser.Time#update
* @param {number} time - The current timestamp, either performance.now or Date.now depending on the browser.
*/
update: function (time) {
@@ -215,7 +212,7 @@ Phaser.Time.prototype = {
/**
* Called when the game enters a paused state.
* @method gamePaused
* @method Phaser.Time#gamePaused
* @private
*/
gamePaused: function () {
@@ -226,7 +223,7 @@ Phaser.Time.prototype = {
/**
* Called when the game resumes from a paused state.
* @method gameResumed
* @method Phaser.Time#gameResumed
* @private
*/
gameResumed: function () {
@@ -240,7 +237,7 @@ Phaser.Time.prototype = {
/**
* How long has passed since the given time.
* @method elapsedSince
* @method Phaser.Time#elapsedSince
* @param {number} since - The time you want to measure against.
* @return {number} The difference between the given time and now.
*/
@@ -250,7 +247,7 @@ Phaser.Time.prototype = {
/**
* How long has passed since the given time (in seconds).
* @method elapsedSecondsSince
* @method Phaser.Time#elapsedSecondsSince
* @param {number} since - The time you want to measure (in seconds).
* @return {number} Duration between given time and now (in seconds).
*/
@@ -260,7 +257,7 @@ Phaser.Time.prototype = {
/**
* Resets the private _started value to now.
* @method reset
* @method Phaser.Time#reset
*/
reset: function () {
this._started = this.now;
+207 -240
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.Easing
*/
/**
* A collection of easing methods defining ease-in ease-out curves.
*
@@ -13,21 +11,20 @@
*/
Phaser.Easing = {
/**
* Linear easing.
*
* @namespace Linear
*/
/**
* Linear easing.
*
* @class Phaser.Easing.Linear
*/
Linear: {
/**
* Ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Linear
*
* @method Phaser.Easing.Linear#In
* @param {number} k - The value to be tweened.
* @returns {number} k^2.
*/
*/
None: function ( k ) {
return k;
@@ -36,21 +33,20 @@ Phaser.Easing = {
},
/**
* Quadratic easing.
*
* @namespace Quadratic
*/
/**
* Quadratic easing.
*
* @class Phaser.Easing.Quadratic
*/
Quadratic: {
/**
* Ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Quadratic
*
* @method Phaser.Easing.Quadratic#In
* @param {number} k - The value to be tweened.
* @returns {number} k^2.
*/
*/
In: function ( k ) {
return k * k;
@@ -59,12 +55,11 @@ Phaser.Easing = {
/**
* Ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Quadratic
*
* @method Phaser.Easing.Quadratic#Out
* @param {number} k - The value to be tweened.
* @returns {number} k* (2-k).
*/
*/
Out: function ( k ) {
return k * ( 2 - k );
@@ -73,12 +68,11 @@ Phaser.Easing = {
/**
* Ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Quadratic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Quadratic#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k;
@@ -88,21 +82,20 @@ Phaser.Easing = {
},
/**
* Cubic easing.
*
* @namespace Cubic
*/
/**
* Cubic easing.
*
* @class Phaser.Easing.Cubic
*/
Cubic: {
/**
* Cubic ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Cubic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Cubic#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
return k * k * k;
@@ -111,12 +104,11 @@ Phaser.Easing = {
/**
* Cubic ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Cubic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Cubic#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
return --k * k * k + 1;
@@ -125,12 +117,11 @@ Phaser.Easing = {
/**
* Cubic ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Cubic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Cubic#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k;
@@ -140,21 +131,20 @@ Phaser.Easing = {
},
/**
* Quartic easing.
*
* @namespace Quartic
*/
/**
* Quartic easing.
*
* @class Phaser.Easing.Quartic
*/
Quartic: {
/**
* Quartic ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Quartic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Quartic#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
return k * k * k * k;
@@ -163,12 +153,11 @@ Phaser.Easing = {
/**
* Quartic ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Quartic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Quartic#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
return 1 - ( --k * k * k * k );
@@ -177,12 +166,11 @@ Phaser.Easing = {
/**
* Quartic ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @returns {number} Description.
* @memberof Quartic
*/
*
* @method Phaser.Easing.Quartic#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
if ( ( k *= 2 ) < 1) return 0.5 * k * k * k * k;
@@ -192,21 +180,20 @@ Phaser.Easing = {
},
/**
* Quintic easing.
*
* @namespace Quintic
*/
/**
* Quintic easing.
*
* @class Phaser.Easing.Quintic
*/
Quintic: {
/**
* Quintic ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Quintic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Quintic#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
return k * k * k * k * k;
@@ -215,12 +202,11 @@ Phaser.Easing = {
/**
* Quintic ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Quintic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Quintic#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
return --k * k * k * k * k + 1;
@@ -229,12 +215,11 @@ Phaser.Easing = {
/**
* Quintic ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Quintic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Quintic#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k * k * k;
@@ -244,21 +229,20 @@ Phaser.Easing = {
},
/**
* Sinusoidal easing.
*
* @namespace Sinusoidal
*/
/**
* Sinusoidal easing.
*
* @class Phaser.Easing.Sinusoidal
*/
Sinusoidal: {
/**
* Sinusoidal ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Sinusoidal
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Sinusoidal#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
return 1 - Math.cos( k * Math.PI / 2 );
@@ -267,12 +251,11 @@ Phaser.Easing = {
/**
* Sinusoidal ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Sinusoidal
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Sinusoidal#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
return Math.sin( k * Math.PI / 2 );
@@ -281,12 +264,11 @@ Phaser.Easing = {
/**
* Sinusoidal ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Sinusoidal
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Sinusoidal#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
return 0.5 * ( 1 - Math.cos( Math.PI * k ) );
@@ -295,21 +277,20 @@ Phaser.Easing = {
},
/**
* Exponential easing.
*
* @namespace Exponential
*/
/**
* Exponential easing.
*
* @class Phaser.Easing.Exponential
*/
Exponential: {
/**
* Exponential ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Exponential
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Exponential#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
return k === 0 ? 0 : Math.pow( 1024, k - 1 );
@@ -318,12 +299,11 @@ Phaser.Easing = {
/**
* Exponential ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Exponential
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Exponential#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
return k === 1 ? 1 : 1 - Math.pow( 2, - 10 * k );
@@ -332,12 +312,11 @@ Phaser.Easing = {
/**
* Exponential ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Exponential
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Exponential#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
if ( k === 0 ) return 0;
@@ -349,21 +328,20 @@ Phaser.Easing = {
},
/**
* Circular easing.
*
* @namespace Circular
*/
/**
* Circular easing.
*
* @class Phaser.Easing.Circular
*/
Circular: {
/**
* Circular ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Circular
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Circular#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
return 1 - Math.sqrt( 1 - k * k );
@@ -372,12 +350,11 @@ Phaser.Easing = {
/**
* Circular ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Circular
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Circular#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
return Math.sqrt( 1 - ( --k * k ) );
@@ -386,12 +363,11 @@ Phaser.Easing = {
/**
* Circular ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Circular
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Circular#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1);
@@ -401,21 +377,20 @@ Phaser.Easing = {
},
/**
* Elastic easing.
*
* @namespace Elastic
*/
/**
* Elastic easing.
*
* @class Phaser.Easing.Elastic
*/
Elastic: {
/**
* Elastic ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Elastic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Elastic#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
var s, a = 0.1, p = 0.4;
@@ -429,12 +404,11 @@ Phaser.Easing = {
/**
* Elastic ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Elastic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Elastic#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
var s, a = 0.1, p = 0.4;
@@ -448,12 +422,11 @@ Phaser.Easing = {
/**
* Elastic ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Elastic
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Elastic#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
var s, a = 0.1, p = 0.4;
@@ -468,21 +441,20 @@ Phaser.Easing = {
},
/**
* Back easing.
*
* @namespace Back
*/
/**
* Back easing.
*
* @class Phaser.Easing.Back
*/
Back: {
/**
* Back ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Back
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Back#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
var s = 1.70158;
@@ -492,12 +464,11 @@ Phaser.Easing = {
/**
* Back ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Back
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Back#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
var s = 1.70158;
@@ -507,12 +478,11 @@ Phaser.Easing = {
/**
* Back ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Back
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Back#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
var s = 1.70158 * 1.525;
@@ -523,21 +493,20 @@ Phaser.Easing = {
},
/**
* Bounce easing.
*
* @namespace Bounce
*/
/**
* Bounce easing.
*
* @class Phaser.Easing.Bounce
*/
Bounce: {
/**
* Bounce ease-in.
*
* @method In
* @param {number} k - Description.
* @memberof Bounce
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Bounce#In
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
In: function ( k ) {
return 1 - Phaser.Easing.Bounce.Out( 1 - k );
@@ -546,12 +515,11 @@ Phaser.Easing = {
/**
* Bounce ease-out.
*
* @method Out
* @param {number} k - Description.
* @memberof Bounce
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Bounce#Out
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
Out: function ( k ) {
if ( k < ( 1 / 2.75 ) ) {
@@ -576,12 +544,11 @@ Phaser.Easing = {
/**
* Bounce ease-in/out.
*
* @method InOut
* @param {number} k - Description.
* @memberof Bounce
* @returns {number} Description.
*/
*
* @method Phaser.Easing.Bounce#InOut
* @param {number} k - The value to be tweened.
* @returns {number} The tweened value.
*/
InOut: function ( k ) {
if ( k < 0.5 ) return Phaser.Easing.Bounce.In( k * 2 ) * 0.5;
+52 -50
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.Tween
*/
/**
* Tween constructor
* Create a new <code>Tween</code>.
@@ -55,6 +53,7 @@ Phaser.Tween = function (object, game) {
/**
* @property {number} _duration - Description.
* @private
* @default
*/
this._duration = 1000;
@@ -148,7 +147,7 @@ Phaser.Tween = function (object, game) {
this._pausedTime = 0;
/**
* @property {boolean} pendingDelete - Description.
* @property {boolean} pendingDelete - If this tween is ready to be deleted by the TweenManager.
* @default
*/
this.pendingDelete = false;
@@ -181,7 +180,7 @@ Phaser.Tween.prototype = {
/**
* Configure the Tween
*
* @method to
* @method Phaser.Tween#to
* @param {object} properties - Properties you want to tween.
* @param {number} duration - Duration of this tween.
* @param {function} ease - Easing function.
@@ -238,9 +237,9 @@ Phaser.Tween.prototype = {
},
/**
* Description.
* Starts the tween running. Can also be called by the autoStart parameter of Tween.to.
*
* @method start
* @method Phaser.Tween#start
* @param {number} time - Description.
* @return {Phaser.Tween} Itself.
*/
@@ -291,9 +290,9 @@ Phaser.Tween.prototype = {
},
/**
* Description.
* Stops the tween if running and removes it from the TweenManager. If there are any onComplete callbacks or events they are not dispatched.
*
* @method stop
* @method Phaser.Tween#stop
* @return {Phaser.Tween} Itself.
*/
stop: function () {
@@ -306,10 +305,10 @@ Phaser.Tween.prototype = {
},
/**
* Description.
* Sets a delay time before this tween will start.
*
* @method delay
* @param {number} amount - Description.
* @method Phaser.Tween#delay
* @param {number} amount - The amount of the delay in ms.
* @return {Phaser.Tween} Itself.
*/
delay: function ( amount ) {
@@ -320,9 +319,9 @@ Phaser.Tween.prototype = {
},
/**
* Description.
* Sets the number of times this tween will repeat.
*
* @method repeat
* @method Phaser.Tween#repeat
* @param {number} times - How many times to repeat.
* @return {Phaser.Tween} Itself.
*/
@@ -334,10 +333,11 @@ Phaser.Tween.prototype = {
},
/**
* Description.
* A tween that has yoyo set to true will run through from start to finish, then reverse from finish to start.
* Used in combination with repeat you can create endless loops.
*
* @method yoyo
* @param {Phaser.Tween} yoyo - Description.
* @method Phaser.Tween#yoyo
* @param {boolean} yoyo - Set to true to yoyo this tween.
* @return {Phaser.Tween} Itself.
*/
yoyo: function( yoyo ) {
@@ -348,10 +348,10 @@ Phaser.Tween.prototype = {
},
/**
* Set easing function.
* Set easing function this tween will use, i.e. Phaser.Easing.Linear.None.
*
* @method easing
* @param {function} easing - Description.
* @method Phaser.Tween#easing
* @param {function} easing - The easing function this tween will use, i.e. Phaser.Easing.Linear.None.
* @return {Phaser.Tween} Itself.
*/
easing: function ( easing ) {
@@ -362,10 +362,10 @@ Phaser.Tween.prototype = {
},
/**
* Set interpolation function.
* Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation.
*
* @method interpolation
* @param {function} interpolation - Description.
* @method Phaser.Tween#interpolation
* @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default)
* @return {Phaser.Tween} Itself.
*/
interpolation: function ( interpolation ) {
@@ -376,9 +376,10 @@ Phaser.Tween.prototype = {
},
/**
* Description.
* You can chain tweens together by passing a reference to the chain function. This enables one tween to call another on completion.
* You can pass as many tweens as you like to this function, they will each be chained in sequence.
*
* @method chain
* @method Phaser.Tween#chain
* @return {Phaser.Tween} Itself.
*/
chain: function () {
@@ -397,19 +398,21 @@ Phaser.Tween.prototype = {
* .to({ x: 0 }, 1000, Phaser.Easing.Linear.None)
* .to({ y: 0 }, 1000, Phaser.Easing.Linear.None)
* .loop();
* @method loop
* @method Phaser.Tween#loop
* @return {Tween} Itself.
*/
loop: function() {
if (this._parent) this.chain(this._parent);
return this;
},
/**
* Description.
* Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope.
*
* @method onStartCallback
* @param {object} callback - Description.
* @method Phaser.Tween#onStartCallback
* @param {function} callback - The callback to invoke on start.
* @return {Phaser.Tween} Itself.
*/
onStartCallback: function ( callback ) {
@@ -420,10 +423,10 @@ Phaser.Tween.prototype = {
},
/**
* Description.
* Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope.
*
* @method onUpdateCallback
* @param {object} callback - Description.
* @method Phaser.Tween#onUpdateCallback
* @param {function} callback - The callback to invoke each time this tween is updated.
* @return {Phaser.Tween} Itself.
*/
onUpdateCallback: function ( callback ) {
@@ -434,10 +437,10 @@ Phaser.Tween.prototype = {
},
/**
* Description.
* Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope.
*
* @method onCompleteCallback
* @param {object} callback - Description.
* @method Phaser.Tween#onCompleteCallback
* @param {function} callback - The callback to invoke on completion.
* @return {Phaser.Tween} Itself.
*/
onCompleteCallback: function ( callback ) {
@@ -448,30 +451,30 @@ Phaser.Tween.prototype = {
},
/**
* Pause.
* Pauses the tween.
*
* @method pause
* @method Phaser.Tween#pause
*/
pause: function () {
this._paused = true;
},
pause: function () {
this._paused = true;
},
/**
* Resume.
* Resumes a paused tween.
*
* @method resume
* @method Phaser.Tween#resume
*/
resume: function () {
this._paused = false;
this._startTime += this.game.time.pauseDuration;
},
resume: function () {
this._paused = false;
this._startTime += this.game.time.pauseDuration;
},
/**
* Description.
* Core tween update function called by the TweenManager. Does not need to be invoked directly.
*
* @method update
* @param {number} time - Description.
* @return {boolean} Description.
* @method Phaser.Tween#update
* @param {number} time - A timestamp passed in by the TweenManager.
* @return {boolean} false if the tween has completed and should be deleted from the manager, otherwise true (still active).
*/
update: function ( time ) {
@@ -602,4 +605,3 @@ Phaser.Tween.prototype = {
}
};
+11 -13
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.TweenManager
*/
/**
* Phaser - TweenManager
*
@@ -14,10 +12,10 @@
* Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated.
* Tweens are hooked into the game clock and pause system, adjusting based on the game state.
*
* TweenManager is based heavily on tween.js by {@link http://soledadpenades.com|sole}.
* TweenManager is based heavily on tween.js by http://soledadpenades.com.
* The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object.
* It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors.
* Please see {@link https://github.com/sole/tween.js} for a full list of contributors.
* Please see https://github.com/sole/tween.js for a full list of contributors.
* @constructor
*
* @param {Phaser.Game} game - A reference to the currently running game.
@@ -49,7 +47,7 @@ Phaser.TweenManager = function (game) {
Phaser.TweenManager.prototype = {
/**
* Description.
* Version number of this library.
* @property {string} REVISION
* @default
*/
@@ -57,7 +55,7 @@ Phaser.TweenManager.prototype = {
/**
* Get all the tween objects in an array.
* @method getAll
* @method Phaser.TweenManager#getAll
* @returns {Phaser.Tween[]} Array with all tween objects.
*/
getAll: function () {
@@ -68,7 +66,7 @@ Phaser.TweenManager.prototype = {
/**
* Remove all tween objects.
* @method removeAll
* @method Phaser.TweenManager#removeAll
*/
removeAll: function () {
@@ -79,7 +77,7 @@ Phaser.TweenManager.prototype = {
/**
* Add a new tween into the TweenManager.
*
* @method add
* @method Phaser.TweenManager#add
* @param {Phaser.Tween} tween - The tween object you want to add.
* @returns {Phaser.Tween} The tween object you added to the manager.
*/
@@ -92,7 +90,7 @@ Phaser.TweenManager.prototype = {
/**
* Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
*
* @method create
* @method Phaser.TweenManager#create
* @param {Object} object - Object the tween will be run on.
* @returns {Phaser.Tween} The newly created tween object.
*/
@@ -105,7 +103,7 @@ Phaser.TweenManager.prototype = {
/**
* Remove a tween from this manager.
*
* @method remove
* @method Phaser.TweenManager#remove
* @param {Phaser.Tween} tween - The tween object you want to remove.
*/
remove: function ( tween ) {
@@ -123,7 +121,7 @@ Phaser.TweenManager.prototype = {
/**
* Update all the tween objects you added to this manager.
*
* @method update
* @method Phaser.TweenManager#update
* @returns {boolean} Return false if there's no tween to update, otherwise return true.
*/
update: function () {
@@ -163,7 +161,7 @@ Phaser.TweenManager.prototype = {
/**
* Pauses all currently running tweens.
*
* @method update
* @method Phaser.TweenManager#update
*/
pauseAll: function () {
@@ -176,7 +174,7 @@ Phaser.TweenManager.prototype = {
/**
* Pauses all currently paused tweens.
*
* @method resumeAll
* @method Phaser.TweenManager#resumeAll
*/
resumeAll: function () {
+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 () {