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
+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.