More docs.

This commit is contained in:
Richard Davey
2013-10-02 12:11:22 +01:00
parent 2a01fbb0e8
commit 852e82d0ca
60 changed files with 39127 additions and 362 deletions
+1
View File
@@ -339,6 +339,7 @@ Object.defineProperty(Phaser.Animation.prototype, "paused", {
/**
* @name Phaser.Animation#frameTotal
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
* @readonly
*/
Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
+2
View File
@@ -259,6 +259,7 @@ Phaser.AnimationManager.prototype = {
/**
* @name Phaser.AnimationManager#frameData
* @property {Phaser.Animation.FrameData} frameData - The current animations FrameData.
* @readonly
*/
Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
@@ -271,6 +272,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
/**
* @name Phaser.AnimationManager#frameTotal
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
* @readonly
*/
Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
+1
View File
@@ -223,6 +223,7 @@ Phaser.Animation.FrameData.prototype = {
/**
* @name Phaser.Animation.FrameData#total
* @property {number} total - The total number of frames in this FrameData set.
* @readonly
*/
Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", {
+1
View File
@@ -1057,6 +1057,7 @@ Phaser.Group.prototype = {
/**
* @name Phaser.Group#length
* @property {number} length - The number of children in this Group.
* @readonly
*/
Object.defineProperty(Phaser.Group.prototype, "length", {
+6 -12
View File
@@ -2,15 +2,13 @@
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.Stage
*/
/**
*
* The Stage controls the canvas on which everything is displayed. It handles display within the browser,
* focus handling, game resizing, scaling and the pause, boot and orientation screens.
*
* @class Stage
* @class Phaser.Stage
* @constructor
* @param {Phaser.Game} game - Game reference to the currently running game.
* @param {number} width - Width of the canvas element.
@@ -69,7 +67,8 @@ Phaser.Stage.prototype = {
/**
* Initialises the stage and adds the event listeners.
* @method boot
* @method Phaser.Stage#boot
* @private
*/
boot: function () {
@@ -98,7 +97,7 @@ Phaser.Stage.prototype = {
/**
* This method is called when the document visibility is changed.
* @method visibilityChange
* @method Phaser.Stage#visibilityChange
* @param {Event} event - Its type will be used to decide whether the game should be paused or not.
*/
visibilityChange: function (event) {
@@ -110,12 +109,10 @@ Phaser.Stage.prototype = {
if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true)
{
// console.log('visibilityChange - hidden', event);
this.game.paused = true;
}
else
{
// console.log('visibilityChange - shown', event);
this.game.paused = false;
}
@@ -124,11 +121,8 @@ Phaser.Stage.prototype = {
};
/**
* Get
* @returns {string} Returns the background color of the stage.
*//**
* Set
* @param {string} The background color you want the stage to have
* @name Phaser.Stage#backgroundColor
* @property {number|string} paused - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000'
*/
Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
+11 -12
View File
@@ -2,10 +2,8 @@
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.State
*/
/**
* This is a base State class which can be extended if you are creating your own game.
* It provides quick access to common functions such as the camera, cache, input, match, sound and more.
@@ -15,13 +13,14 @@
*/
Phaser.State = function () {
/**
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = null;
/**
* @property {Description} add - Description.
* @property {Phaser.GameObjectFactory} add - Reference to the GameObjectFactory.
* @default
*/
this.add = null;
@@ -106,7 +105,7 @@ Phaser.State.prototype = {
* Override this method to add some load operations.
* If you need to use the loader, you may need to use them here.
*
* @method preload
* @method Phaser.State#preload
*/
preload: function () {
},
@@ -114,7 +113,7 @@ Phaser.State.prototype = {
/**
* Put update logic here.
*
* @method loadUpdate
* @method Phaser.State#loadUpdate
*/
loadUpdate: function () {
},
@@ -122,7 +121,7 @@ Phaser.State.prototype = {
/**
* Put render operations here.
*
* @method loadRender
* @method Phaser.State#loadRender
*/
loadRender: function () {
},
@@ -131,7 +130,7 @@ Phaser.State.prototype = {
* This method is called after the game engine successfully switches states.
* Feel free to add any setup code here (do not load anything here, override preload() instead).
*
* @method create
* @method Phaser.State#create
*/
create: function () {
},
@@ -139,7 +138,7 @@ Phaser.State.prototype = {
/**
* Put update logic here.
*
* @method update
* @method Phaser.State#update
*/
update: function () {
},
@@ -147,7 +146,7 @@ Phaser.State.prototype = {
/**
* Put render operations here.
*
* @method render
* @method Phaser.State#render
*/
render: function () {
},
@@ -155,14 +154,14 @@ Phaser.State.prototype = {
/**
* This method will be called when game paused.
*
* @method paused
* @method Phaser.State#paused
*/
paused: function () {
},
/**
* This method will be called when the state is destroyed.#
* @method destroy
* This method will be called when the state is destroyed.
* @method Phaser.State#destroy
*/
destroy: function () {
}
+26 -24
View File
@@ -2,16 +2,15 @@
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.StateManager
*/
/**
* Description.
* The State Manager is responsible for loading, setting up and switching game states.
*
* @class Phaser.StateManager
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {Description} pendingState - Description.
* @param {Phaser.State|Object} [pendingState=null] - A State object to seed the manager with.
*/
Phaser.StateManager = function (game, pendingState) {
@@ -130,7 +129,8 @@ Phaser.StateManager.prototype = {
/**
* Description.
* @method boot
* @method Phaser.StateManager#boot
* @private
*/
boot: function () {
@@ -157,7 +157,7 @@ Phaser.StateManager.prototype = {
/**
* Add a new State.
* @method add
* @method Phaser.StateManager#add
* @param key {string} - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
* @param state {State} - The state you want to switch to.
* @param autoStart {boolean} - Start the state immediately after creating it? (default true)
@@ -211,7 +211,7 @@ Phaser.StateManager.prototype = {
/**
* Delete the given state.
* @method remove
* @method Phaser.StateManager#remove
* @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
*/
remove: function (key) {
@@ -239,7 +239,7 @@ Phaser.StateManager.prototype = {
/**
* Start the given state
* @method start
* @method Phaser.StateManager#start
* @param {string} key - The key of the state you want to start.
* @param {boolean} [clearWorld] - clear everything in the world? (Default to true)
* @param {boolean} [clearCache] - clear asset cache? (Default to false and ONLY available when clearWorld=true)
@@ -317,7 +317,7 @@ Phaser.StateManager.prototype = {
/**
* Used by onInit and onShutdown when those functions don't exist on the state
* @method dummy
* @method Phaser.StateManager#dummy
* @private
*/
dummy: function () {
@@ -325,7 +325,7 @@ Phaser.StateManager.prototype = {
/**
* Description.
* @method checkState
* @method Phaser.StateManager#checkState
* @param {string} key - The key of the state you want to check.
* @return {boolean} Description.
*/
@@ -362,9 +362,10 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method link
* @param {string} key - Description.
* Links game properties to the State given by the key.
* @method Phaser.StateManager#link
* @param {string} key - State key.
* @protected
*/
link: function (key) {
@@ -388,9 +389,10 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method setCurrentState
* @param {string} key - Description.
* Sets the current State. Should not be called directly (use StateManager.start)
* @method Phaser.StateManager#setCurrentState
* @param {string} key - State key.
* @protected
*/
setCurrentState: function (key) {
@@ -421,8 +423,8 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method loadComplete
* @method Phaser.StateManager#loadComplete
* @protected
*/
loadComplete: function () {
@@ -442,8 +444,8 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method update
* @method Phaser.StateManager#update
* @protected
*/
update: function () {
@@ -462,8 +464,8 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method preRender
* @method Phaser.StateManager#preRender
* @protected
*/
preRender: function () {
@@ -475,8 +477,8 @@ Phaser.StateManager.prototype = {
},
/**
* Description.
* @method render
* @method Phaser.StateManager#render
* @protected
*/
render: function () {
@@ -496,7 +498,7 @@ Phaser.StateManager.prototype = {
/**
* Nuke the entire game from orbit
* @method destroy
* @method Phaser.StateManager#destroy
*/
destroy: function () {
+22 -34
View File
@@ -2,11 +2,9 @@
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.World
*/
/**
*
* "This world is but a canvas to our imagination." - Henry David Thoreau
* <p>
* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
@@ -51,7 +49,8 @@ Phaser.World.prototype = {
/**
* Initialises the game world.
*
* @method boot
* @method Phaser.World#boot
* @protected
*/
boot: function () {
@@ -66,7 +65,7 @@ Phaser.World.prototype = {
/**
* This is called automatically every frame, and is where main logic happens.
*
* @method update
* @method Phaser.World#update
*/
update: function () {
@@ -99,7 +98,7 @@ Phaser.World.prototype = {
/**
* This is called automatically every frame, and is where main logic happens.
* @method update
* @method Phaser.World#postUpdate
*/
postUpdate: function () {
@@ -123,7 +122,7 @@ Phaser.World.prototype = {
/**
* Updates the size of this world.
* @method setSize
* @method Phaser.World#setSize
* @param {number} width - New width of the world.
* @param {number} height - New height of the world.
*/
@@ -143,7 +142,7 @@ Phaser.World.prototype = {
/**
* Destroyer of worlds.
* @method destroy
* @method Phaser.World#destroy
*/
destroy: function () {
@@ -158,28 +157,16 @@ Phaser.World.prototype = {
};
// Getters / Setters
/**
* Get
* @returns {Description}
*//**
* Set
* @param {Description} value - Description
* @name Phaser.World#width
* @property {number} width - Gets or sets the current width of the game world.
*/
Object.defineProperty(Phaser.World.prototype, "width", {
/**
* @method width
* @return {number} The current width of the game world
*/
get: function () {
return this.bounds.width;
},
/**
* @method width
* @return {number} Sets the width of the game world
*/
set: function (value) {
this.bounds.width = value;
}
@@ -187,11 +174,8 @@ Object.defineProperty(Phaser.World.prototype, "width", {
});
/**
* Get
* @returns {number} The current height of the game world.
*//**
* Sets the width of the game world.
* @param {Description} value - Height of the game world.
* @name Phaser.World#height
* @property {number} height - Gets or sets the current height of the game world.
*/
Object.defineProperty(Phaser.World.prototype, "height", {
@@ -206,8 +190,9 @@ Object.defineProperty(Phaser.World.prototype, "height", {
});
/**
* Get
* @returns {number} return the X position of the center point of the world
* @name Phaser.World#centerX
* @property {number} centerX - Gets the X position corresponding to the center point of the world.
* @readonly
*/
Object.defineProperty(Phaser.World.prototype, "centerX", {
@@ -218,8 +203,9 @@ Object.defineProperty(Phaser.World.prototype, "centerX", {
});
/**
* Get
* @returns {number} return the Y position of the center point of the world
* @name Phaser.World#centerY
* @property {number} centerY - Gets the Y position corresponding to the center point of the world.
* @readonly
*/
Object.defineProperty(Phaser.World.prototype, "centerY", {
@@ -230,8 +216,9 @@ Object.defineProperty(Phaser.World.prototype, "centerY", {
});
/**
* Get
* @returns {number} a random integer which is lesser or equal to the current width of the game world
* @name Phaser.World#randomX
* @property {number} randomX - Gets a random integer which is lesser than or equal to the current width of the game world.
* @readonly
*/
Object.defineProperty(Phaser.World.prototype, "randomX", {
@@ -242,8 +229,9 @@ Object.defineProperty(Phaser.World.prototype, "randomX", {
});
/**
* Get
* @returns {number} a random integer which is lesser or equal to the current height of the game world
* @name Phaser.World#randomY
* @property {number} randomY - Gets a random integer which is lesser than or equal to the current height of the game world.
* @readonly
*/
Object.defineProperty(Phaser.World.prototype, "randomY", {
+41 -67
View File
@@ -2,7 +2,6 @@
* @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.Circle
*/
/**
@@ -56,7 +55,7 @@ Phaser.Circle.prototype = {
/**
* The circumference of the circle.
* @method circumference
* @method Phaser.Circle#circumference
* @return {number}
**/
circumference: function () {
@@ -65,7 +64,7 @@ Phaser.Circle.prototype = {
/**
* Sets the members of Circle to the specified values.
* @method setTo
* @method Phaser.Circle#setTo
* @param {number} x - The x coordinate of the center of the circle.
* @param {number} y - The y coordinate of the center of the circle.
* @param {number} diameter - The diameter of the circle in pixels.
@@ -81,7 +80,7 @@ Phaser.Circle.prototype = {
/**
* Copies the x, y and diameter properties from any given object to this Circle.
* @method copyFrom
* @method Phaser.Circle#copyFrom
* @param {any} source - The object to copy from.
* @return {Circle} This Circle object.
**/
@@ -91,7 +90,7 @@ Phaser.Circle.prototype = {
/**
* Copies the x, y and diameter properties from this Circle to any given object.
* @method copyTo
* @method Phaser.Circle#copyTo
* @param {any} dest - The object to copy to.
* @return {Object} This dest object.
**/
@@ -105,7 +104,7 @@ Phaser.Circle.prototype = {
/**
* Returns the distance from the center of the Circle object to the given object
* (can be Circle, Point or anything with x/y properties)
* @method distance
* @method Phaser.Circle#distance
* @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object.
* @param {boolean} [round] - Round the distance to the nearest integer (default false).
* @return {number} The distance between this Point object and the destination Point object.
@@ -127,7 +126,7 @@ Phaser.Circle.prototype = {
/**
* Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object.
* @method clone
* @method Phaser.Circle#clone
* @param {Phaser.Circle} out - Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned.
* @return {Phaser.Circle} The cloned Circle object.
*/
@@ -141,7 +140,7 @@ Phaser.Circle.prototype = {
/**
* Return true if the given x/y coordinates are within this Circle object.
* @method contains
* @method Phaser.Circle#contains
* @param {number} x - The X value of the coordinate to test.
* @param {number} y - The Y value of the coordinate to test.
* @return {boolean} True if the coordinates are within this circle, otherwise false.
@@ -152,7 +151,7 @@ Phaser.Circle.prototype = {
/**
* Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
* @method circumferencePoint
* @method Phaser.Circle#circumferencePoint
* @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from.
* @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)?
* @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created.
@@ -164,7 +163,7 @@ Phaser.Circle.prototype = {
/**
* Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts.
* @method offset
* @method Phaser.Circle#offset
* @param {number} dx - Moves the x value of the Circle object by this amount.
* @param {number} dy - Moves the y value of the Circle object by this amount.
* @return {Circle} This Circle object.
@@ -177,7 +176,7 @@ Phaser.Circle.prototype = {
/**
* Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter.
* @method offsetPoint
* @method Phaser.Circle#offsetPoint
* @param {Point} point A Point object to use to offset this Circle object (or any valid object with exposed x and y properties).
* @return {Circle} This Circle object.
**/
@@ -187,7 +186,7 @@ Phaser.Circle.prototype = {
/**
* Returns a string representation of this object.
* @method toString
* @method Phaser.Circle#toString
* @return {string} a string representation of the instance.
**/
toString: function () {
@@ -196,14 +195,10 @@ Phaser.Circle.prototype = {
};
// Getters / Setters
/**
* Get the diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2.
* @return {number}
*//**
* Set the diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2.
* @param {number} value - The diameter of the circle.
* The largest distance between any two points on the circle. The same as the radius * 2.
* @name Phaser.Circle#diameter
* @property {number} diameter - Gets or sets the diameter of the circle.
*/
Object.defineProperty(Phaser.Circle.prototype, "diameter", {
@@ -211,11 +206,6 @@ Object.defineProperty(Phaser.Circle.prototype, "diameter", {
return this._diameter;
},
/**
* The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2.
* @method diameter
* @param {number} The diameter of the circle.
**/
set: function (value) {
if (value > 0) {
this._diameter = value;
@@ -226,11 +216,9 @@ Object.defineProperty(Phaser.Circle.prototype, "diameter", {
});
/**
* Get the radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter.
* @return {number}
*//**
* Set
* @param {number} value - The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter.
* The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter.
* @name Phaser.Circle#radius
* @property {number} radius - Gets or sets the radius of the circle.
*/
Object.defineProperty(Phaser.Circle.prototype, "radius", {
@@ -248,11 +236,9 @@ Object.defineProperty(Phaser.Circle.prototype, "radius", {
});
/**
* Get the x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
* @return {number} The x coordinate of the leftmost point of the circle.
*//**
* Set the x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
* @param {number} value - The value to adjust the position of the leftmost point of the circle by.
* The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
* @name Phaser.Circle#left
* @propety {number} left - Gets or sets the value of the leftmost point of the circle.
*/
Object.defineProperty(Phaser.Circle.prototype, "left", {
@@ -272,11 +258,9 @@ Object.defineProperty(Phaser.Circle.prototype, "left", {
});
/**
* Get the x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
* @return {number} The x coordinate of the rightmost point of the circle.
*//**
* Set the x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
* @param {number} value - The amount to adjust the diameter of the circle by.
* The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
* @name Phaser.Circle#right
* @property {number} right - Gets or sets the value of the rightmost point of the circle.
*/
Object.defineProperty(Phaser.Circle.prototype, "right", {
@@ -296,11 +280,9 @@ Object.defineProperty(Phaser.Circle.prototype, "right", {
});
/**
* Get the sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter.
* @return {number}
*//**
* The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter.
* @param {number} value - The amount to adjust the height of the circle by.
* @name Phaser.Circle#top
* @property {number} top - Gets or sets the top of the circle.
*/
Object.defineProperty(Phaser.Circle.prototype, "top", {
@@ -320,11 +302,9 @@ Object.defineProperty(Phaser.Circle.prototype, "top", {
});
/**
* Get the sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter.
* @return {number}
*//**
* Set the sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter.
* @param {number} value - The value to adjust the height of the circle by.
* The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter.
* @name Phaser.Circle#bottom
* @property {number} bottom - Gets or sets the bottom of the circle.
*/
Object.defineProperty(Phaser.Circle.prototype, "bottom", {
@@ -345,8 +325,10 @@ Object.defineProperty(Phaser.Circle.prototype, "bottom", {
});
/**
* Gets the area of this Circle.
* @return {number} This area of this circle.
* The area of this Circle.
* @name Phaser.Circle#area
* @property {number} area - The area of this circle.
* @readonly
*/
Object.defineProperty(Phaser.Circle.prototype, "area", {
@@ -361,11 +343,10 @@ Object.defineProperty(Phaser.Circle.prototype, "area", {
});
/**
* Determines whether or not this Circle object is empty.
* @return {boolean} A value of true if the Circle objects diameter is less than or equal to 0; otherwise false.
*//**
* Sets all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0.
* @param {Description} value - Description.
* Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false.
* If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0.
* @name Phaser.Circle#empty
* @property {boolean} empty - Gets or sets the empty state of the circle.
*/
Object.defineProperty(Phaser.Circle.prototype, "empty", {
@@ -373,22 +354,15 @@ Object.defineProperty(Phaser.Circle.prototype, "empty", {
return (this._diameter == 0);
},
/**
*
* @method setEmpty
* @return {Circle} This Circle object
**/
set: function (value) {
this.setTo(0, 0, 0);
}
});
// Statics
/**
* Return true if the given x/y coordinates are within the Circle object.
* @method contains
* @method Phaser.Circle.contains
* @param {Phaser.Circle} a - The Circle to be checked.
* @param {number} x - The X value of the coordinate to test.
* @param {number} y - The Y value of the coordinate to test.
@@ -412,7 +386,7 @@ Phaser.Circle.contains = function (a, x, y) {
/**
* Determines whether the two Circle objects match. This method compares the x, y and diameter properties.
* @method equals
* @method Phaser.Circle.equals
* @param {Phaser.Circle} a - The first Circle object.
* @param {Phaser.Circle} b - The second Circle object.
* @return {boolean} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false.
@@ -424,7 +398,7 @@ Phaser.Circle.equals = function (a, b) {
/**
* Determines whether the two Circle objects intersect.
* This method checks the radius distances between the two Circle objects to see if they intersect.
* @method intersects
* @method Phaser.Circle.intersects
* @param {Phaser.Circle} a - The first Circle object.
* @param {Phaser.Circle} b - The second Circle object.
* @return {boolean} A value of true if the specified object intersects with this Circle object; otherwise false.
@@ -435,7 +409,7 @@ Phaser.Circle.intersects = function (a, b) {
/**
* Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
* @method circumferencePoint
* @method Phaser.Circle.circumferencePoint
* @param {Phaser.Circle} a - The first Circle object.
* @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from.
* @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)?
@@ -460,7 +434,7 @@ Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) {
/**
* Checks if the given Circle and Rectangle objects intersect.
* @method intersectsRectangle
* @method Phaser.Circle.intersectsRectangle
* @param {Phaser.Circle} c - The Circle object to test.
* @param {Phaser.Rectangle} r - The Rectangle object to test.
* @return {boolean} True if the two objects intersect, otherwise false.
+49 -26
View File
@@ -2,12 +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.Point
*/
/**
* Creates a new Point. If you pass no parameters a Point is created set to (0,0).
* @class Point
* @class Phaser.Point
* @classdesc The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
* @constructor
* @param {number} x The horizontal position of this Point (default 0)
@@ -34,7 +33,7 @@ Phaser.Point.prototype = {
/**
* Copies the x and y properties from any given object to this Point.
* @method copyFrom
* @method Phaser.Point#copyFrom
* @param {any} source - The object to copy from.
* @return {Point} This Point object.
**/
@@ -44,7 +43,7 @@ Phaser.Point.prototype = {
/**
* Inverts the x and y values of this Point
* @method invert
* @method Phaser.Point#invert
* @return {Point} This Point object.
**/
invert: function () {
@@ -53,7 +52,7 @@ Phaser.Point.prototype = {
/**
* Sets the x and y values of this Point object to the given coordinates.
* @method setTo
* @method Phaser.Point#setTo
* @param {number} x - The horizontal position of this point.
* @param {number} y - The vertical position of this point.
* @return {Point} This Point object. Useful for chaining method calls.
@@ -64,6 +63,13 @@ Phaser.Point.prototype = {
return this;
},
/**
* Adds the given x and y values to this Point.
* @method Phaser.Point#add
* @param {number} x - The value to add to Point.x.
* @param {number} y - The value to add to Point.y.
* @return {Phaser.Point} This Point object. Useful for chaining method calls.
**/
add: function (x, y) {
this.x += x;
@@ -72,6 +78,13 @@ Phaser.Point.prototype = {
},
/**
* Subtracts the given x and y values from this Point.
* @method Phaser.Point#subtract
* @param {number} x - The value to subtract from Point.x.
* @param {number} y - The value to subtract from Point.y.
* @return {Phaser.Point} This Point object. Useful for chaining method calls.
**/
subtract: function (x, y) {
this.x -= x;
@@ -80,6 +93,13 @@ Phaser.Point.prototype = {
},
/**
* Multiplies Point.x and Point.y by the given x and y values.
* @method Phaser.Point#multiply
* @param {number} x - The value to multiply Point.x by.
* @param {number} y - The value to multiply Point.x by.
* @return {Phaser.Point} This Point object. Useful for chaining method calls.
**/
multiply: function (x, y) {
this.x *= x;
@@ -88,6 +108,13 @@ Phaser.Point.prototype = {
},
/**
* Divides Point.x and Point.y by the given x and y values.
* @method Phaser.Point#divide
* @param {number} x - The value to divide Point.x by.
* @param {number} y - The value to divide Point.x by.
* @return {Phaser.Point} This Point object. Useful for chaining method calls.
**/
divide: function (x, y) {
this.x /= x;
@@ -98,7 +125,7 @@ Phaser.Point.prototype = {
/**
* Clamps the x value of this Point to be between the given min and max.
* @method clampX
* @method Phaser.Point#clampX
* @param {number} min - The minimum value to clamp this Point to.
* @param {number} max - The maximum value to clamp this Point to.
* @return {Phaser.Point} This Point object.
@@ -112,7 +139,7 @@ Phaser.Point.prototype = {
/**
* Clamps the y value of this Point to be between the given min and max
* @method clampY
* @method Phaser.Point#clampY
* @param {number} min - The minimum value to clamp this Point to.
* @param {number} max - The maximum value to clamp this Point to.
* @return {Phaser.Point} This Point object.
@@ -126,7 +153,7 @@ Phaser.Point.prototype = {
/**
* Clamps this Point object values to be between the given min and max.
* @method clamp
* @method Phaser.Point#clamp
* @param {number} min - The minimum value to clamp this Point to.
* @param {number} max - The maximum value to clamp this Point to.
* @return {Phaser.Point} This Point object.
@@ -141,7 +168,7 @@ Phaser.Point.prototype = {
/**
* Creates a copy of the given Point.
* @method clone
* @method Phaser.Point#clone
* @param {Phaser.Point} [output] Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
* @return {Phaser.Point} The new Point object.
*/
@@ -155,7 +182,7 @@ Phaser.Point.prototype = {
/**
* Copies the x and y properties from any given object to this Point.
* @method copyFrom
* @method Phaser.Point#copyFrom
* @param {any} source - The object to copy from.
* @return {Point} This Point object.
**/
@@ -165,7 +192,7 @@ Phaser.Point.prototype = {
/**
* Copies the x and y properties from this Point to any given object.
* @method copyTo
* @method Phaser.Point#copyTo
* @param {any} dest - The object to copy to.
* @return {Object} The dest object.
**/
@@ -180,7 +207,7 @@ Phaser.Point.prototype = {
/**
* Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties)
* @method distance
* @method Phaser.Point#distance
* @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object.
* @param {boolean} [round] - Round the distance to the nearest integer (default false).
* @return {number} The distance between this Point object and the destination Point object.
@@ -193,7 +220,7 @@ Phaser.Point.prototype = {
/**
* Determines whether the given objects x/y values are equal to this Point object.
* @method equals
* @method Phaser.Point#equals
* @param {Phaser.Point} a - The first object to compare.
* @return {boolean} A value of true if the Points are equal, otherwise false.
*/
@@ -203,7 +230,7 @@ Phaser.Point.prototype = {
/**
* Rotates this Point around the x/y coordinates given to the desired angle.
* @method rotate
* @method Phaser.Point#rotate
* @param {number} x - The x coordinate of the anchor point
* @param {number} y - The y coordinate of the anchor point
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to.
@@ -217,7 +244,7 @@ Phaser.Point.prototype = {
/**
* Returns a string representation of this object.
* @method toString
* @method Phaser.Point#toString
* @return {string} A string representation of the instance.
**/
toString: function () {
@@ -226,11 +253,9 @@ Phaser.Point.prototype = {
};
// Statics
/**
* Adds the coordinates of two points together to create a new point.
* @method add
* @method Phaser.Point.add
* @param {Phaser.Point} a - The first Point object.
* @param {Phaser.Point} b - The second Point object.
* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
@@ -249,7 +274,7 @@ Phaser.Point.add = function (a, b, out) {
/**
* Subtracts the coordinates of two points to create a new point.
* @method subtract
* @method Phaser.Point.subtract
* @param {Phaser.Point} a - The first Point object.
* @param {Phaser.Point} b - The second Point object.
* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
@@ -268,7 +293,7 @@ Phaser.Point.subtract = function (a, b, out) {
/**
* Multiplies the coordinates of two points to create a new point.
* @method subtract
* @method Phaser.Point.multiply
* @param {Phaser.Point} a - The first Point object.
* @param {Phaser.Point} b - The second Point object.
* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
@@ -287,7 +312,7 @@ Phaser.Point.multiply = function (a, b, out) {
/**
* Divides the coordinates of two points to create a new point.
* @method subtract
* @method Phaser.Point.divide
* @param {Phaser.Point} a - The first Point object.
* @param {Phaser.Point} b - The second Point object.
* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
@@ -306,7 +331,7 @@ Phaser.Point.divide = function (a, b, out) {
/**
* Determines whether the two given Point objects are equal. They are considered equal if they have the same x and y values.
* @method equals
* @method Phaser.Point.equals
* @param {Phaser.Point} a - The first Point object.
* @param {Phaser.Point} b - The second Point object.
* @return {boolean} A value of true if the Points are equal, otherwise false.
@@ -317,7 +342,7 @@ Phaser.Point.equals = function (a, b) {
/**
* Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties).
* @method distance
* @method Phaser.Point.distance
* @param {object} a - The target object. Must have visible x and y properties that represent the center of the object.
* @param {object} b - The target object. Must have visible x and y properties that represent the center of the object.
* @param {boolean} [round] - Round the distance to the nearest integer (default false).
@@ -340,7 +365,7 @@ Phaser.Point.distance = function (a, b, round) {
/**
* Rotates a Point around the x/y coordinates given to the desired angle.
* @method rotate
* @method Phaser.Point.rotate
* @param {Phaser.Point} a - The Point object to rotate.
* @param {number} x - The x coordinate of the anchor point
* @param {number} y - The y coordinate of the anchor point
@@ -368,5 +393,3 @@ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) {
return a.setTo(x + distance * Math.cos(angle), y + distance * Math.sin(angle));
};
+64 -84
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.Rectangle
*/
/**
* Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created.
*
@@ -50,7 +48,7 @@ Phaser.Rectangle.prototype = {
/**
* Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
* @method offset
* @method Phaser.Rectangle#offset
* @param {number} dx - Moves the x value of the Rectangle object by this amount.
* @param {number} dy - Moves the y value of the Rectangle object by this amount.
* @return {Rectangle} This Rectangle object.
@@ -66,7 +64,7 @@ Phaser.Rectangle.prototype = {
/**
* Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.
* @method offsetPoint
* @method Phaser.Rectangle#offsetPoint
* @param {Point} point - A Point object to use to offset this Rectangle object.
* @return {Rectangle} This Rectangle object.
**/
@@ -76,7 +74,7 @@ Phaser.Rectangle.prototype = {
/**
* Sets the members of Rectangle to the specified values.
* @method setTo
* @method Phaser.Rectangle#setTo
* @param {number} x - The x coordinate of the top-left corner of the Rectangle.
* @param {number} y - The y coordinate of the top-left corner of the Rectangle.
* @param {number} width - The width of the Rectangle in pixels.
@@ -96,7 +94,7 @@ Phaser.Rectangle.prototype = {
/**
* Runs Math.floor() on both the x and y values of this Rectangle.
* @method floor
* @method Phaser.Rectangle#floor
**/
floor: function () {
@@ -107,7 +105,7 @@ Phaser.Rectangle.prototype = {
/**
* Copies the x, y, width and height properties from any given object to this Rectangle.
* @method copyFrom
* @method Phaser.Rectangle#copyFrom
* @param {any} source - The object to copy from.
* @return {Rectangle} This Rectangle object.
**/
@@ -117,7 +115,7 @@ Phaser.Rectangle.prototype = {
/**
* Copies the x, y, width and height properties from this Rectangle to any given object.
* @method copyTo
* @method Phaser.Rectangle#copyTo
* @param {any} source - The object to copy to.
* @return {object} This object.
**/
@@ -134,7 +132,7 @@ Phaser.Rectangle.prototype = {
/**
* Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
* @method inflate
* @method Phaser.Rectangle#inflate
* @param {number} dx - The amount to be added to the left side of the Rectangle.
* @param {number} dy - The amount to be added to the bottom side of the Rectangle.
* @return {Phaser.Rectangle} This Rectangle object.
@@ -145,7 +143,7 @@ Phaser.Rectangle.prototype = {
/**
* The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
* @method size
* @method Phaser.Rectangle#size
* @param {Phaser.Point} [output] - Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.
* @return {Phaser.Point} The size of the Rectangle object.
*/
@@ -155,7 +153,7 @@ Phaser.Rectangle.prototype = {
/**
* Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
* @method clone
* @method Phaser.Rectangle#clone
* @param {Phaser.Rectangle} [output] - Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.
* @return {Phaser.Rectangle}
*/
@@ -165,7 +163,7 @@ Phaser.Rectangle.prototype = {
/**
* Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
* @method contains
* @method Phaser.Rectangle#contains
* @param {number} x - The x coordinate of the point to test.
* @param {number} y - The y coordinate of the point to test.
* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
@@ -177,7 +175,7 @@ Phaser.Rectangle.prototype = {
/**
* Determines whether the first Rectangle object is fully contained within the second Rectangle object.
* A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
* @method containsRect
* @method Phaser.Rectangle#containsRect
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
*/
@@ -188,7 +186,7 @@ Phaser.Rectangle.prototype = {
/**
* Determines whether the two Rectangles are equal.
* This method compares the x, y, width and height properties of each Rectangle.
* @method equals
* @method Phaser.Rectangle#equals
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @return {boolean} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.
*/
@@ -198,7 +196,7 @@ Phaser.Rectangle.prototype = {
/**
* If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.
* @method intersection
* @method Phaser.Rectangle#intersection
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @param {Phaser.Rectangle} out - Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
* @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0.
@@ -210,7 +208,7 @@ Phaser.Rectangle.prototype = {
/**
* Determines whether the two Rectangles intersect with each other.
* This method checks the x, y, width, and height properties of the Rectangles.
* @method intersects
* @method Phaser.Rectangle#intersects
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0.
* @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false.
@@ -221,7 +219,7 @@ Phaser.Rectangle.prototype = {
/**
* Determines whether the object specified intersects (overlaps) with the given values.
* @method intersectsRaw
* @method Phaser.Rectangle#intersectsRaw
* @param {number} left - Description.
* @param {number} right - Description.
* @param {number} top - Description.
@@ -235,7 +233,7 @@ Phaser.Rectangle.prototype = {
/**
* Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.
* @method union
* @method Phaser.Rectangle#union
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
* @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles.
@@ -246,7 +244,7 @@ Phaser.Rectangle.prototype = {
/**
* Returns a string representation of this object.
* @method toString
* @method Phaser.Rectangle#toString
* @return {string} A string representation of the instance.
**/
toString: function () {
@@ -255,11 +253,10 @@ Phaser.Rectangle.prototype = {
};
// Getters / Setters
/**
* Get half of the width of the Rectangle.
* @return {number}
* @name Phaser.Rectangle#halfWidth
* @property {number} halfWidth - Half of the width of the Rectangle.
* @readonly
*/
Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", {
@@ -270,8 +267,9 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", {
});
/**
* Get galf of the height of the Rectangle.
* @return {number}
* @name Phaser.Rectangle#halfHeight
* @property {number} halfHeight - Half of the height of the Rectangle.
* @readonly
*/
Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
@@ -283,10 +281,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
/**
* The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
* @return {number}
*//**
* The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
* @param {number} value
* @name Phaser.Rectangle#bottom
* @property {number} bottom - The sum of the y and height properties.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "bottom", {
@@ -305,11 +301,9 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottom", {
});
/**
* Get the location of the Rectangles bottom right corner as a Point object.
* @return {Phaser.Point}
*//**
* Sets the bottom-right corner of the Rectangle, determined by the values of the given Point object.
* @param {Phaser.Point} value
* The location of the Rectangles bottom right corner as a Point object.
* @name Phaser.Rectangle#bottom
* @property {Phaser.Point} bottomRight - Gets or sets the location of the Rectangles bottom right corner as a Point object.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
@@ -326,10 +320,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
/**
* The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property.
* @return {number}
*//**
* The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties.* However it does affect the width, whereas changing the x value does not affect the width property.
* @param {number} value
* @name Phaser.Rectangle#left
* @property {number} left - The x coordinate of the left of the Rectangle.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "left", {
@@ -349,13 +341,9 @@ Object.defineProperty(Phaser.Rectangle.prototype, "left", {
});
/**
* The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties.
* However it does affect the width property.
* @return {number}
*//**
* The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties.
* However it does affect the width property.
* @param {number} value
* The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property.
* @name Phaser.Rectangle#right
* @property {number} right - The sum of the x and width properties.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "right", {
@@ -375,7 +363,9 @@ Object.defineProperty(Phaser.Rectangle.prototype, "right", {
/**
* The volume of the Rectangle derived from width * height.
* @return {number}
* @name Phaser.Rectangle#volume
* @property {number} volume - The volume of the Rectangle derived from width * height.
* @readonly
*/
Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
@@ -387,7 +377,9 @@ Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
/**
* The perimeter size of the Rectangle. This is the sum of all 4 sides.
* @return {number}
* @name Phaser.Rectangle#perimeter
* @property {number} perimeter - The perimeter size of the Rectangle. This is the sum of all 4 sides.
* @readonly
*/
Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
@@ -399,10 +391,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
/**
* The x coordinate of the center of the Rectangle.
* @return {number}
*//**
* The x coordinate of the center of the Rectangle.
* @param {number} value
* @name Phaser.Rectangle#centerX
* @property {number} centerX - The x coordinate of the center of the Rectangle.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
@@ -418,10 +408,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
/**
* The y coordinate of the center of the Rectangle.
* @return {number}
*//**
* The y coordinate of the center of the Rectangle.
* @param {number} value
* @name Phaser.Rectangle#centerY
* @property {number} centerY - The y coordinate of the center of the Rectangle.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
@@ -438,11 +426,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
/**
* The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties.
* However it does affect the height property, whereas changing the y value does not affect the height property.
* @return {number}
*//**
* The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties.
* However it does affect the height property, whereas changing the y value does not affect the height property.
* @param {number} value
* @name Phaser.Rectangle#top
* @property {number} top - The y coordinate of the top of the Rectangle.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "top", {
@@ -462,11 +447,9 @@ Object.defineProperty(Phaser.Rectangle.prototype, "top", {
});
/**
* Get the location of the Rectangles top left corner as a Point object.
* @return {Phaser.Point}
*//**
* The location of the Rectangles top-left corner, determined by the x and y coordinates of the Point.
* @param {Phaser.Point} value - Description.
* The location of the Rectangles top left corner as a Point object.
* @name Phaser.Rectangle#topLeft
* @property {Phaser.Point} topLeft - The location of the Rectangles top left corner as a Point object.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
@@ -482,11 +465,10 @@ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
});
/**
* Determines whether or not this Rectangle object is empty.
* @return {boolean}
*//**
* Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0.
* @param {Description} value
* Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0.
* If set to true then all of the Rectangle properties are set to 0.
* @name Phaser.Rectangle#empty
* @property {boolean} empty - Gets or sets the Rectangles empty state.
*/
Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
@@ -500,11 +482,9 @@ Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
});
// Statics
/**
* Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
* @method inflate
* @method Phaser.Rectangle.inflate
* @param {Phaser.Rectangle} a - The Rectangle object.
* @param {number} dx - The amount to be added to the left side of the Rectangle.
* @param {number} dy - The amount to be added to the bottom side of the Rectangle.
@@ -520,7 +500,7 @@ Phaser.Rectangle.inflate = function (a, dx, dy) {
/**
* Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.
* @method inflatePoint
* @method Phaser.Rectangle.inflatePoint
* @param {Phaser.Rectangle} a - The Rectangle object.
* @param {Phaser.Point} point - The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.
* @return {Phaser.Rectangle} The Rectangle object.
@@ -531,7 +511,7 @@ Phaser.Rectangle.inflatePoint = function (a, point) {
/**
* The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
* @method size
* @method Phaser.Rectangle.size
* @param {Phaser.Rectangle} a - The Rectangle object.
* @param {Phaser.Point} [output] - Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.
* @return {Phaser.Point} The size of the Rectangle object
@@ -543,7 +523,7 @@ Phaser.Rectangle.size = function (a, output) {
/**
* Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
* @method clone
* @method Phaser.Rectangle.clone
* @param {Phaser.Rectangle} a - The Rectangle object.
* @param {Phaser.Rectangle} [output] - Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.
* @return {Phaser.Rectangle}
@@ -555,7 +535,7 @@ Phaser.Rectangle.clone = function (a, output) {
/**
* Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
* @method contains
* @method Phaser.Rectangle.contains
* @param {Phaser.Rectangle} a - The Rectangle object.
* @param {number} x - The x coordinate of the point to test.
* @param {number} y - The y coordinate of the point to test.
@@ -567,7 +547,7 @@ Phaser.Rectangle.contains = function (a, x, y) {
/**
* Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.
* @method containsPoint
* @method Phaser.Rectangle.containsPoint
* @param {Phaser.Rectangle} a - The Rectangle object.
* @param {Phaser.Point} point - The point object being checked. Can be Point or any object with .x and .y values.
* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
@@ -579,7 +559,7 @@ Phaser.Rectangle.containsPoint = function (a, point) {
/**
* Determines whether the first Rectangle object is fully contained within the second Rectangle object.
* A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
* @method containsRect
* @method Phaser.Rectangle.containsRect
* @param {Phaser.Rectangle} a - The first Rectangle object.
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
@@ -599,7 +579,7 @@ Phaser.Rectangle.containsRect = function (a, b) {
/**
* Determines whether the two Rectangles are equal.
* This method compares the x, y, width and height properties of each Rectangle.
* @method equals
* @method Phaser.Rectangle.equals
* @param {Phaser.Rectangle} a - The first Rectangle object.
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @return {boolean} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.
@@ -610,7 +590,7 @@ Phaser.Rectangle.equals = function (a, b) {
/**
* If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.
* @method intersection
* @method Phaser.Rectangle.intersection
* @param {Phaser.Rectangle} a - The first Rectangle object.
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
@@ -635,7 +615,7 @@ Phaser.Rectangle.intersection = function (a, b, out) {
/**
* Determines whether the two Rectangles intersect with each other.
* This method checks the x, y, width, and height properties of the Rectangles.
* @method intersects
* @method Phaser.Rectangle.intersects
* @param {Phaser.Rectangle} a - The first Rectangle object.
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0
@@ -651,7 +631,7 @@ Phaser.Rectangle.intersects = function (a, b, tolerance) {
/**
* Determines whether the object specified intersects (overlaps) with the given values.
* @method intersectsRaw
* @method Phaser.Rectangle.intersectsRaw
* @param {number} left - Description.
* @param {number} right - Description.
* @param {number} top - Description.
@@ -669,7 +649,7 @@ Phaser.Rectangle.intersectsRaw = function (a, left, right, top, bottom, toleranc
/**
* Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.
* @method union
* @method Phaser.Rectangle.union
* @param {Phaser.Rectangle} a - The first Rectangle object.
* @param {Phaser.Rectangle} b - The second Rectangle object.
* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.