mirror of
https://github.com/wassname/phaser.git
synced 2026-08-10 12:30:48 +08:00
Adding docs.
This commit is contained in:
+105
-107
@@ -1,13 +1,19 @@
|
||||
/**
|
||||
* Phaser - Circle
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created.
|
||||
* @class Circle
|
||||
* @classdesc Phaser - Circle
|
||||
* @constructor
|
||||
* @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.
|
||||
* @return {Circle} This circle object
|
||||
* @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.
|
||||
* @return {Phaser.Circle} This circle object
|
||||
**/
|
||||
Phaser.Circle = function (x, y, diameter) {
|
||||
|
||||
@@ -16,23 +22,27 @@ Phaser.Circle = function (x, y, diameter) {
|
||||
diameter = diameter || 0;
|
||||
|
||||
/**
|
||||
* The x coordinate of the center of the circle
|
||||
* @property x
|
||||
* @type Number
|
||||
* @property {number} x - The x coordinate of the center of the circle.
|
||||
**/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* The y coordinate of the center of the circle
|
||||
* @property y
|
||||
* @type Number
|
||||
* @property {number} y - The y coordinate of the center of the circle.
|
||||
**/
|
||||
this.y = y;
|
||||
|
||||
/**
|
||||
* @property {number} _diameter - The diameter of the circle.
|
||||
* @private
|
||||
**/
|
||||
this._diameter = diameter;
|
||||
|
||||
if (diameter > 0)
|
||||
{
|
||||
/**
|
||||
* @property {number} _radius - The radius of the circle.
|
||||
* @private
|
||||
**/
|
||||
this._radius = diameter * 0.5;
|
||||
}
|
||||
else
|
||||
@@ -47,7 +57,7 @@ Phaser.Circle.prototype = {
|
||||
/**
|
||||
* The circumference of the circle.
|
||||
* @method circumference
|
||||
* @return {Number}
|
||||
* @return {number}
|
||||
**/
|
||||
circumference: function () {
|
||||
return 2 * (Math.PI * this._radius);
|
||||
@@ -56,10 +66,10 @@ Phaser.Circle.prototype = {
|
||||
/**
|
||||
* Sets the members of Circle to the specified values.
|
||||
* @method 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.
|
||||
* @return {Circle} This circle object
|
||||
* @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.
|
||||
* @return {Circle} This circle object.
|
||||
**/
|
||||
setTo: function (x, y, diameter) {
|
||||
this.x = x;
|
||||
@@ -96,9 +106,9 @@ 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
|
||||
* @param {object} dest The target object. Must have visible x and y properties that represent the center of the object.
|
||||
* @param {bool} [optional] round Round the distance to the nearest integer (default false)
|
||||
* @return {Number} The distance between this Point object and the destination Point object.
|
||||
* @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object.
|
||||
* @param {bool} [round] - Round the distance to the nearest integer (default false).
|
||||
* @return {number} The distance between this Point object and the destination Point object.
|
||||
*/
|
||||
distance: function (dest, round) {
|
||||
|
||||
@@ -118,7 +128,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
|
||||
* @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.
|
||||
* @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.
|
||||
*/
|
||||
clone: function(out) {
|
||||
@@ -132,8 +142,8 @@ Phaser.Circle.prototype = {
|
||||
/**
|
||||
* Return true if the given x/y coordinates are within this Circle object.
|
||||
* @method contains
|
||||
* @param {Number} x The X value of the coordinate to test.
|
||||
* @param {Number} y The Y value of the coordinate to test.
|
||||
* @param {number} x - The X value of the coordinate to test.
|
||||
* @param {number} y - The Y value of the coordinate to test.
|
||||
* @return {bool} True if the coordinates are within this circle, otherwise false.
|
||||
*/
|
||||
contains: function (x, y) {
|
||||
@@ -143,9 +153,9 @@ 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
|
||||
* @param {Number} angle The angle in radians (unless asDegrees is true) to return the point from.
|
||||
* @param {bool} asDegrees Is the given angle in radians (false) or degrees (true)?
|
||||
* @param {Phaser.Point} [optional] output An optional Point object to put the result in to. If none specified a new Point object will be created.
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from.
|
||||
* @param {bool} 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.
|
||||
* @return {Phaser.Point} The Point object holding the result.
|
||||
*/
|
||||
circumferencePoint: function (angle, asDegrees, out) {
|
||||
@@ -155,8 +165,8 @@ Phaser.Circle.prototype = {
|
||||
/**
|
||||
* Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts.
|
||||
* @method 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.
|
||||
* @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.
|
||||
**/
|
||||
offset: function (dx, dy) {
|
||||
@@ -188,13 +198,15 @@ 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.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "diameter", {
|
||||
|
||||
/**
|
||||
* The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2.
|
||||
* @method diameter
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this._diameter;
|
||||
},
|
||||
@@ -213,22 +225,19 @@ 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.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "radius", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method radius
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this._radius;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method radius
|
||||
* @param {Number} The radius of the circle.
|
||||
**/
|
||||
set: function (value) {
|
||||
if (value > 0) {
|
||||
this._radius = value;
|
||||
@@ -238,22 +247,19 @@ 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.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "left", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method left
|
||||
* @return {Number} The x coordinate of the leftmost point of the circle.
|
||||
**/
|
||||
get: function () {
|
||||
return this.x - this._radius;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method left
|
||||
* @param {Number} The value to adjust the position of the leftmost point of the circle by.
|
||||
**/
|
||||
set: function (value) {
|
||||
if (value > this.x) {
|
||||
this._radius = 0;
|
||||
@@ -265,22 +271,19 @@ 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.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "right", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method right
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this.x + this._radius;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method right
|
||||
* @param {Number} The amount to adjust the diameter of the circle by.
|
||||
**/
|
||||
set: function (value) {
|
||||
if (value < this.x) {
|
||||
this._radius = 0;
|
||||
@@ -292,22 +295,19 @@ 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.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "top", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method bottom
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this.y - this._radius;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method bottom
|
||||
* @param {Number} The amount to adjust the height of the circle by.
|
||||
**/
|
||||
set: function (value) {
|
||||
if (value > this.y) {
|
||||
this._radius = 0;
|
||||
@@ -319,22 +319,19 @@ 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.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "bottom", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method bottom
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this.y + this._radius;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method bottom
|
||||
* @param {Number} The value to adjust the height of the circle by.
|
||||
**/
|
||||
set: function (value) {
|
||||
|
||||
if (value < this.y) {
|
||||
@@ -347,13 +344,12 @@ Object.defineProperty(Phaser.Circle.prototype, "bottom", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Gets the area of this Circle.
|
||||
* @return {number} This area of this circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "area", {
|
||||
|
||||
/**
|
||||
* Gets the area of this Circle.
|
||||
* @method area
|
||||
* @return {Number} This area of this circle.
|
||||
**/
|
||||
get: function () {
|
||||
if (this._radius > 0) {
|
||||
return Math.PI * this._radius * this._radius;
|
||||
@@ -364,19 +360,21 @@ Object.defineProperty(Phaser.Circle.prototype, "area", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Determines whether or not this Circle object is empty.
|
||||
* @return {bool} 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.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "empty", {
|
||||
|
||||
/**
|
||||
* Determines whether or not this Circle object is empty.
|
||||
* @method empty
|
||||
* @return {bool} A value of true if the Circle objects diameter is less than or equal to 0; otherwise false.
|
||||
**/
|
||||
get: function () {
|
||||
return (this._diameter == 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0.
|
||||
*
|
||||
* @method setEmpty
|
||||
* @return {Circle} This Circle object
|
||||
**/
|
||||
@@ -391,9 +389,9 @@ Object.defineProperty(Phaser.Circle.prototype, "empty", {
|
||||
/**
|
||||
* Return true if the given x/y coordinates are within the Circle object.
|
||||
* @method 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.
|
||||
* @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.
|
||||
* @return {bool} True if the coordinates are within this circle, otherwise false.
|
||||
*/
|
||||
Phaser.Circle.contains = function (a, x, y) {
|
||||
@@ -415,8 +413,8 @@ 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
|
||||
* @param {Phaser.Circle} a The first Circle object.
|
||||
* @param {Phaser.Circle} b The second Circle object.
|
||||
* @param {Phaser.Circle} a - The first Circle object.
|
||||
* @param {Phaser.Circle} b - The second Circle object.
|
||||
* @return {bool} 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.
|
||||
*/
|
||||
Phaser.Circle.equals = function (a, b) {
|
||||
@@ -427,8 +425,8 @@ 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
|
||||
* @param {Phaser.Circle} a The first Circle object.
|
||||
* @param {Phaser.Circle} b The second Circle object.
|
||||
* @param {Phaser.Circle} a - The first Circle object.
|
||||
* @param {Phaser.Circle} b - The second Circle object.
|
||||
* @return {bool} A value of true if the specified object intersects with this Circle object; otherwise false.
|
||||
*/
|
||||
Phaser.Circle.intersects = function (a, b) {
|
||||
@@ -438,10 +436,10 @@ 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
|
||||
* @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 {bool} asDegrees Is the given angle in radians (false) or degrees (true)?
|
||||
* @param {Phaser.Point} [optional] output An optional Point object to put the result in to. If none specified a new Point object will be created.
|
||||
* @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 {bool} 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.
|
||||
* @return {Phaser.Point} The Point object holding the result.
|
||||
*/
|
||||
Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) {
|
||||
@@ -463,8 +461,8 @@ Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) {
|
||||
/**
|
||||
* Checks if the given Circle and Rectangle objects intersect.
|
||||
* @method intersectsRectangle
|
||||
* @param {Phaser.Circle} c The Circle object to test.
|
||||
* @param {Phaser.Rectangle} r The Rectangle object to test.
|
||||
* @param {Phaser.Circle} c - The Circle object to test.
|
||||
* @param {Phaser.Rectangle} r - The Rectangle object to test.
|
||||
* @return {bool} True if the two objects intersect, otherwise false.
|
||||
*/
|
||||
Phaser.Circle.intersectsRectangle = function (c, r) {
|
||||
|
||||
+57
-53
@@ -1,17 +1,14 @@
|
||||
/**
|
||||
* Phaser - Point
|
||||
*
|
||||
* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
|
||||
*
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Point
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new Point. If you pass no parameters a Point is created set to (0,0).
|
||||
* @class 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)
|
||||
* @param {Number} y The vertical position of this Point (default 0)
|
||||
@@ -21,7 +18,14 @@ Phaser.Point = function (x, y) {
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
|
||||
/**
|
||||
* @property {number} x - The x coordinate of the point.
|
||||
**/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* @property {number} y - The y coordinate of the point.
|
||||
**/
|
||||
this.y = y;
|
||||
|
||||
};
|
||||
@@ -50,8 +54,8 @@ Phaser.Point.prototype = {
|
||||
/**
|
||||
* Sets the x and y values of this Point object to the given coordinates.
|
||||
* @method setTo
|
||||
* @param {Number} x - The horizontal position of this point.
|
||||
* @param {Number} y - The vertical position of this point.
|
||||
* @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.
|
||||
**/
|
||||
setTo: function (x, y) {
|
||||
@@ -93,10 +97,10 @@ Phaser.Point.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Clamps the x value of this Point to be between the given min and max
|
||||
* Clamps the x value of this Point to be between the given min and max.
|
||||
* @method clampX
|
||||
* @param {Number} min The minimum value to clamp this Point to
|
||||
* @param {Number} max The maximum value to clamp this Point to
|
||||
* @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.
|
||||
*/
|
||||
clampX: function (min, max) {
|
||||
@@ -109,8 +113,8 @@ Phaser.Point.prototype = {
|
||||
/**
|
||||
* Clamps the y value of this Point to be between the given min and max
|
||||
* @method clampY
|
||||
* @param {Number} min The minimum value to clamp this Point to
|
||||
* @param {Number} max The maximum value to clamp this Point to
|
||||
* @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.
|
||||
*/
|
||||
clampY: function (min, max) {
|
||||
@@ -121,10 +125,10 @@ Phaser.Point.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Clamps this Point object values to be between the given min and max
|
||||
* Clamps this Point object values to be between the given min and max.
|
||||
* @method clamp
|
||||
* @param {Number} min The minimum value to clamp this Point to
|
||||
* @param {Number} max The maximum value to clamp this Point to
|
||||
* @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.
|
||||
*/
|
||||
clamp: function (min, max) {
|
||||
@@ -138,7 +142,7 @@ Phaser.Point.prototype = {
|
||||
/**
|
||||
* Creates a copy of the given Point.
|
||||
* @method 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.
|
||||
* @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.
|
||||
*/
|
||||
clone: function (output) {
|
||||
@@ -177,9 +181,9 @@ 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
|
||||
* @param {object} dest The target object. Must have visible x and y properties that represent the center of the object.
|
||||
* @param {bool} [optional] round Round the distance to the nearest integer (default false)
|
||||
* @return {Number} The distance between this Point object and the destination Point object.
|
||||
* @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object.
|
||||
* @param {bool} [round] - Round the distance to the nearest integer (default false).
|
||||
* @return {number} The distance between this Point object and the destination Point object.
|
||||
*/
|
||||
distance: function (dest, round) {
|
||||
|
||||
@@ -190,7 +194,7 @@ Phaser.Point.prototype = {
|
||||
/**
|
||||
* Determines whether the given objects x/y values are equal to this Point object.
|
||||
* @method equals
|
||||
* @param {Phaser.Point} a The first object to compare.
|
||||
* @param {Phaser.Point} a - The first object to compare.
|
||||
* @return {bool} A value of true if the Points are equal, otherwise false.
|
||||
*/
|
||||
equals: function (a) {
|
||||
@@ -200,12 +204,12 @@ Phaser.Point.prototype = {
|
||||
/**
|
||||
* Rotates this Point around the x/y coordinates given to the desired angle.
|
||||
* @method 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.
|
||||
* @param {bool} asDegrees Is the given rotation in radians (false) or degrees (true)?
|
||||
* @param {Number} distance An optional distance constraint between the Point and the anchor.
|
||||
* @return {Phaser.Point} The modified point object
|
||||
* @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.
|
||||
* @param {bool} asDegrees - Is the given rotation in radians (false) or degrees (true)?
|
||||
* @param {number} [distance] - An optional distance constraint between the Point and the anchor.
|
||||
* @return {Phaser.Point} The modified point object.
|
||||
*/
|
||||
rotate: function (x, y, angle, asDegrees, distance) {
|
||||
return Phaser.Point.rotate(this, x, y, angle, asDegrees, distance);
|
||||
@@ -214,7 +218,7 @@ Phaser.Point.prototype = {
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the instance.
|
||||
* @return {string} A string representation of the instance.
|
||||
**/
|
||||
toString: function () {
|
||||
return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
|
||||
@@ -227,9 +231,9 @@ Phaser.Point.prototype = {
|
||||
/**
|
||||
* Adds the coordinates of two points together to create a new point.
|
||||
* @method 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.
|
||||
* @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.
|
||||
* @return {Phaser.Point} The new Point object.
|
||||
*/
|
||||
Phaser.Point.add = function (a, b, out) {
|
||||
@@ -246,9 +250,9 @@ Phaser.Point.add = function (a, b, out) {
|
||||
/**
|
||||
* Subtracts the coordinates of two points to create a new point.
|
||||
* @method 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.
|
||||
* @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.
|
||||
* @return {Phaser.Point} The new Point object.
|
||||
*/
|
||||
Phaser.Point.subtract = function (a, b, out) {
|
||||
@@ -265,9 +269,9 @@ Phaser.Point.subtract = function (a, b, out) {
|
||||
/**
|
||||
* Multiplies the coordinates of two points to create a new point.
|
||||
* @method 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.
|
||||
* @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.
|
||||
* @return {Phaser.Point} The new Point object.
|
||||
*/
|
||||
Phaser.Point.multiply = function (a, b, out) {
|
||||
@@ -284,9 +288,9 @@ Phaser.Point.multiply = function (a, b, out) {
|
||||
/**
|
||||
* Divides the coordinates of two points to create a new point.
|
||||
* @method 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.
|
||||
* @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.
|
||||
* @return {Phaser.Point} The new Point object.
|
||||
*/
|
||||
Phaser.Point.divide = function (a, b, out) {
|
||||
@@ -303,8 +307,8 @@ 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
|
||||
* @param {Phaser.Point} a The first Point object.
|
||||
* @param {Phaser.Point} b The second Point object.
|
||||
* @param {Phaser.Point} a - The first Point object.
|
||||
* @param {Phaser.Point} b - The second Point object.
|
||||
* @return {bool} A value of true if the Points are equal, otherwise false.
|
||||
*/
|
||||
Phaser.Point.equals = function (a, b) {
|
||||
@@ -312,11 +316,11 @@ 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)
|
||||
* Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties).
|
||||
* @method 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 {bool} [optional] round Round the distance to the nearest integer (default false)
|
||||
* @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 {bool} [round] - Round the distance to the nearest integer (default false).
|
||||
* @return {Number} The distance between this Point object and the destination Point object.
|
||||
*/
|
||||
Phaser.Point.distance = function (a, b, round) {
|
||||
@@ -337,13 +341,13 @@ Phaser.Point.distance = function (a, b, round) {
|
||||
/**
|
||||
* Rotates a Point around the x/y coordinates given to the desired angle.
|
||||
* @method 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
|
||||
* @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to.
|
||||
* @param {bool} asDegrees Is the given rotation in radians (false) or degrees (true)?
|
||||
* @param {Number} distance An optional distance constraint between the Point and the anchor.
|
||||
* @return {Phaser.Point} The modified point object
|
||||
* @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
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to.
|
||||
* @param {bool} asDegrees - Is the given rotation in radians (false) or degrees (true)?
|
||||
* @param {number} distance - An optional distance constraint between the Point and the anchor.
|
||||
* @return {Phaser.Point} The modified point object.
|
||||
*/
|
||||
Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) {
|
||||
|
||||
|
||||
+172
-202
@@ -1,13 +1,21 @@
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* @class Rectangle
|
||||
* @class Phaser.Rectangle
|
||||
* @constructor
|
||||
* @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.
|
||||
* @param {Number} height The height of the Rectangle in pixels.
|
||||
* @return {Rectangle} This Rectangle object
|
||||
* @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.
|
||||
* @param {number} height - The height of the Rectangle in pixels.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
Phaser.Rectangle = function (x, y, width, height) {
|
||||
|
||||
@@ -17,31 +25,23 @@ Phaser.Rectangle = function (x, y, width, height) {
|
||||
height = height || 0;
|
||||
|
||||
/**
|
||||
* @property x
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
* @property {number} x - Description.
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* @property y
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
* @property {number} y - Description.
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
/**
|
||||
* @property width
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
* @property {number} width - Description.
|
||||
*/
|
||||
this.width = width;
|
||||
|
||||
/**
|
||||
* @property height
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
* @property {number} height - Description.
|
||||
*/
|
||||
this.height = height;
|
||||
|
||||
};
|
||||
@@ -51,8 +51,8 @@ Phaser.Rectangle.prototype = {
|
||||
/**
|
||||
* Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
|
||||
* @method 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.
|
||||
* @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.
|
||||
**/
|
||||
offset: function (dx, dy) {
|
||||
@@ -67,7 +67,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
|
||||
* @param {Point} point A Point object to use to offset this Rectangle object.
|
||||
* @param {Point} point - A Point object to use to offset this Rectangle object.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
offsetPoint: function (point) {
|
||||
@@ -77,10 +77,10 @@ Phaser.Rectangle.prototype = {
|
||||
/**
|
||||
* Sets the members of Rectangle to the specified values.
|
||||
* @method 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.
|
||||
* @param {Number} height The height of the Rectangle in pixels.
|
||||
* @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.
|
||||
* @param {number} height - The height of the Rectangle in pixels.
|
||||
* @return {Rectangle} This Rectangle object
|
||||
**/
|
||||
setTo: function (x, y, width, height) {
|
||||
@@ -135,8 +135,8 @@ 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
|
||||
* @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.
|
||||
* @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.
|
||||
*/
|
||||
inflate: function (dx, dy) {
|
||||
@@ -146,8 +146,8 @@ 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
|
||||
* @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
|
||||
* @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.
|
||||
*/
|
||||
size: function (output) {
|
||||
return Phaser.Rectangle.size(this, output);
|
||||
@@ -156,8 +156,8 @@ 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
|
||||
* @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}
|
||||
* @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}
|
||||
*/
|
||||
clone: function (output) {
|
||||
return Phaser.Rectangle.clone(this, output);
|
||||
@@ -166,8 +166,8 @@ Phaser.Rectangle.prototype = {
|
||||
/**
|
||||
* Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
|
||||
* @method contains
|
||||
* @param {Number} x The x coordinate of the point to test.
|
||||
* @param {Number} y The y coordinate of the point to test.
|
||||
* @param {number} x - The x coordinate of the point to test.
|
||||
* @param {number} y - The y coordinate of the point to test.
|
||||
* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
*/
|
||||
contains: function (x, y) {
|
||||
@@ -178,7 +178,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
|
||||
* @param {Phaser.Rectangle} b The second Rectangle object.
|
||||
* @param {Phaser.Rectangle} b - The second Rectangle object.
|
||||
* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
*/
|
||||
containsRect: function (b) {
|
||||
@@ -189,7 +189,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
|
||||
* @param {Phaser.Rectangle} b The second Rectangle object.
|
||||
* @param {Phaser.Rectangle} b - The second Rectangle object.
|
||||
* @return {bool} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.
|
||||
*/
|
||||
equals: function (b) {
|
||||
@@ -199,8 +199,8 @@ 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
|
||||
* @param {Phaser.Rectangle} b The second Rectangle object.
|
||||
* @param {Phaser.Rectangle} output 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.
|
||||
* @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.
|
||||
*/
|
||||
intersection: function (b, out) {
|
||||
@@ -211,8 +211,8 @@ 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
|
||||
* @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
|
||||
* @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 {bool} A value of true if the specified object intersects with this Rectangle object; otherwise false.
|
||||
*/
|
||||
intersects: function (b, tolerance) {
|
||||
@@ -222,11 +222,11 @@ Phaser.Rectangle.prototype = {
|
||||
/**
|
||||
* Determines whether the object specified intersects (overlaps) with the given values.
|
||||
* @method intersectsRaw
|
||||
* @param {Number} left
|
||||
* @param {Number} right
|
||||
* @param {Number} top
|
||||
* @param {Number} bottomt
|
||||
* @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0
|
||||
* @param {number} left - Description.
|
||||
* @param {number} right - Description.
|
||||
* @param {number} top - Description.
|
||||
* @param {number} bottomt - Description.
|
||||
* @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0
|
||||
* @return {bool} A value of true if the specified object intersects with the Rectangle; otherwise false.
|
||||
*/
|
||||
intersectsRaw: function (left, right, top, bottom, tolerance) {
|
||||
@@ -236,8 +236,8 @@ 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
|
||||
* @param {Phaser.Rectangle} b The second Rectangle object.
|
||||
* @param {Phaser.Rectangle} output 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.
|
||||
* @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.
|
||||
*/
|
||||
union: function (b, out) {
|
||||
@@ -247,7 +247,7 @@ Phaser.Rectangle.prototype = {
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the instance.
|
||||
* @return {string} A string representation of the instance.
|
||||
**/
|
||||
toString: function () {
|
||||
return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]";
|
||||
@@ -257,48 +257,43 @@ Phaser.Rectangle.prototype = {
|
||||
|
||||
// Getters / Setters
|
||||
|
||||
/**
|
||||
* Get half of the width of the Rectangle.
|
||||
* @return {number}
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", {
|
||||
|
||||
/**
|
||||
* Half of the width of the Rectangle
|
||||
* @property halfWidth
|
||||
* @type Number
|
||||
**/
|
||||
get: function () {
|
||||
return Math.round(this.width / 2);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get galf of the height of the Rectangle.
|
||||
* @return {number}
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
|
||||
|
||||
/**
|
||||
* Half of the height of the Rectangle
|
||||
* @property halfHeight
|
||||
* @type Number
|
||||
**/
|
||||
get: function () {
|
||||
return Math.round(this.height / 2);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "bottom", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method bottom
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this.y + this.height;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method bottom
|
||||
* @param {Number} value
|
||||
**/
|
||||
|
||||
set: function (value) {
|
||||
if (value <= this.y) {
|
||||
this.height = 0;
|
||||
@@ -309,21 +304,19 @@ 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
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
|
||||
|
||||
/**
|
||||
* Get the location of the Rectangles bottom right corner as a Point object.
|
||||
* @return {Phaser.Point} The new Point object.
|
||||
*/
|
||||
get: function () {
|
||||
return new Phaser.Point(this.right, this.bottom);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the bottom-right corner of the Rectangle, determined by the values of the given Point object.
|
||||
* @method bottomRight
|
||||
* @param {Point} value
|
||||
**/
|
||||
set: function (value) {
|
||||
this.right = value.x;
|
||||
this.bottom = value.y;
|
||||
@@ -331,23 +324,19 @@ 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
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "left", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method left
|
||||
* @ return {number}
|
||||
**/
|
||||
|
||||
get: function () {
|
||||
return this.x;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method left
|
||||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
if (value >= this.right) {
|
||||
this.width = 0;
|
||||
@@ -359,24 +348,21 @@ 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
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "right", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method right
|
||||
* @return {Number}
|
||||
**/
|
||||
|
||||
get: function () {
|
||||
return this.x + this.width;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method right
|
||||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
if (value <= this.x) {
|
||||
this.width = 0;
|
||||
@@ -387,94 +373,83 @@ Object.defineProperty(Phaser.Rectangle.prototype, "right", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The volume of the Rectangle derived from width * height.
|
||||
* @return {number}
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
|
||||
|
||||
/**
|
||||
* The volume of the Rectangle derived from width * height
|
||||
* @method volume
|
||||
* @return {Number}
|
||||
**/
|
||||
|
||||
get: function () {
|
||||
return this.width * this.height;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The perimeter size of the Rectangle. This is the sum of all 4 sides.
|
||||
* @return {number}
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
|
||||
|
||||
/**
|
||||
* The perimeter size of the Rectangle. This is the sum of all 4 sides.
|
||||
* @method perimeter
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return (this.width * 2) + (this.height * 2);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The x coordinate of the center of the Rectangle.
|
||||
* @return {number}
|
||||
*//**
|
||||
* The x coordinate of the center of the Rectangle.
|
||||
* @param {number} value
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
|
||||
|
||||
/**
|
||||
* The x coordinate of the center of the Rectangle.
|
||||
* @method centerX
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this.x + this.halfWidth;
|
||||
},
|
||||
|
||||
/**
|
||||
* The x coordinate of the center of the Rectangle.
|
||||
* @method centerX
|
||||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
this.x = value - this.halfWidth;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The y coordinate of the center of the Rectangle.
|
||||
* @return {number}
|
||||
*//**
|
||||
* The y coordinate of the center of the Rectangle.
|
||||
* @param {number} value
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
|
||||
|
||||
/**
|
||||
* The y coordinate of the center of the Rectangle.
|
||||
* @method centerY
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this.y + this.halfHeight;
|
||||
},
|
||||
|
||||
/**
|
||||
* The y coordinate of the center of the Rectangle.
|
||||
* @method centerY
|
||||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
this.y = value - this.halfHeight;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "top", {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method top
|
||||
* @return {Number}
|
||||
**/
|
||||
get: function () {
|
||||
return this.y;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method top
|
||||
* @param {Number} value
|
||||
**/
|
||||
set: function (value) {
|
||||
if (value >= this.bottom) {
|
||||
this.height = 0;
|
||||
@@ -486,21 +461,19 @@ 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.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
|
||||
|
||||
/**
|
||||
* Get the location of the Rectangles top left corner as a Point object.
|
||||
* @return {Phaser.Point} The new Point object.
|
||||
*/
|
||||
get: function () {
|
||||
return new Phaser.Point(this.x, this.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* The location of the Rectangles top-left corner, determined by the x and y coordinates of the Point.
|
||||
* @method topLeft
|
||||
* @param {Point} value
|
||||
**/
|
||||
|
||||
set: function (value) {
|
||||
this.x = value.x;
|
||||
this.y = value.y;
|
||||
@@ -508,22 +481,19 @@ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Determines whether or not this Rectangle object is empty.
|
||||
* @return {bool}
|
||||
*//**
|
||||
* 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
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
|
||||
|
||||
/**
|
||||
* Determines whether or not this Rectangle object is empty.
|
||||
* @method isEmpty
|
||||
* @return {bool} A value of true if the Rectangle objects width or height is less than or equal to 0; otherwise false.
|
||||
**/
|
||||
get: function () {
|
||||
return (!this.width || !this.height);
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @method setEmpty
|
||||
* @return {Rectangle} This Rectangle object
|
||||
**/
|
||||
set: function (value) {
|
||||
this.setTo(0, 0, 0, 0);
|
||||
}
|
||||
@@ -535,9 +505,9 @@ Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
|
||||
/**
|
||||
* 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
|
||||
* @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.
|
||||
* @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.
|
||||
* @return {Phaser.Rectangle} This Rectangle object.
|
||||
*/
|
||||
Phaser.Rectangle.inflate = function (a, dx, dy) {
|
||||
@@ -551,8 +521,8 @@ 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
|
||||
* @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.
|
||||
* @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.
|
||||
*/
|
||||
Phaser.Rectangle.inflatePoint = function (a, point) {
|
||||
@@ -562,8 +532,8 @@ 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
|
||||
* @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.
|
||||
* @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
|
||||
*/
|
||||
Phaser.Rectangle.size = function (a, output) {
|
||||
@@ -574,8 +544,8 @@ 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
|
||||
* @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.
|
||||
* @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}
|
||||
*/
|
||||
Phaser.Rectangle.clone = function (a, output) {
|
||||
@@ -586,9 +556,9 @@ Phaser.Rectangle.clone = function (a, output) {
|
||||
/**
|
||||
* Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
|
||||
* @method 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.
|
||||
* @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.
|
||||
* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
*/
|
||||
Phaser.Rectangle.contains = function (a, x, y) {
|
||||
@@ -598,8 +568,8 @@ 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
|
||||
* @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.
|
||||
* @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 {bool} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
*/
|
||||
Phaser.Rectangle.containsPoint = function (a, point) {
|
||||
@@ -610,8 +580,8 @@ 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
|
||||
* @param {Phaser.Rectangle} a The first Rectangle object.
|
||||
* @param {Phaser.Rectangle} b The second Rectangle object.
|
||||
* @param {Phaser.Rectangle} a - The first Rectangle object.
|
||||
* @param {Phaser.Rectangle} b - The second Rectangle object.
|
||||
* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
*/
|
||||
Phaser.Rectangle.containsRect = function (a, b) {
|
||||
@@ -630,8 +600,8 @@ 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
|
||||
* @param {Phaser.Rectangle} a The first Rectangle object.
|
||||
* @param {Phaser.Rectangle} b The second Rectangle object.
|
||||
* @param {Phaser.Rectangle} a - The first Rectangle object.
|
||||
* @param {Phaser.Rectangle} b - The second Rectangle object.
|
||||
* @return {bool} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.
|
||||
*/
|
||||
Phaser.Rectangle.equals = function (a, b) {
|
||||
@@ -641,14 +611,14 @@ 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
|
||||
* @param {Phaser.Rectangle} a The first Rectangle object.
|
||||
* @param {Phaser.Rectangle} b The second Rectangle object.
|
||||
* @param {Phaser.Rectangle} output 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.
|
||||
* @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.
|
||||
* @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.
|
||||
*/
|
||||
Phaser.Rectangle.intersection = function (a, b, out) {
|
||||
|
||||
out = out || new Phaser.Rectangle;
|
||||
out = out || new Phaser.Rectangle;
|
||||
|
||||
if (Phaser.Rectangle.intersects(a, b))
|
||||
{
|
||||
@@ -666,9 +636,9 @@ 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
|
||||
* @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
|
||||
* @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
|
||||
* @return {bool} A value of true if the specified object intersects with this Rectangle object; otherwise false.
|
||||
*/
|
||||
Phaser.Rectangle.intersects = function (a, b, tolerance) {
|
||||
@@ -682,11 +652,11 @@ Phaser.Rectangle.intersects = function (a, b, tolerance) {
|
||||
/**
|
||||
* Determines whether the object specified intersects (overlaps) with the given values.
|
||||
* @method intersectsRaw
|
||||
* @param {Number} left
|
||||
* @param {Number} right
|
||||
* @param {Number} top
|
||||
* @param {Number} bottomt
|
||||
* @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0
|
||||
* @param {number} left - Description.
|
||||
* @param {number} right - Description.
|
||||
* @param {number} top - Description.
|
||||
* @param {number} bottom - Description.
|
||||
* @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0
|
||||
* @return {bool} A value of true if the specified object intersects with the Rectangle; otherwise false.
|
||||
*/
|
||||
Phaser.Rectangle.intersectsRaw = function (a, left, right, top, bottom, tolerance) {
|
||||
@@ -700,9 +670,9 @@ 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
|
||||
* @param {Phaser.Rectangle} a The first Rectangle object.
|
||||
* @param {Phaser.Rectangle} b The second Rectangle object.
|
||||
* @param {Phaser.Rectangle} output 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.
|
||||
* @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.
|
||||
* @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles.
|
||||
*/
|
||||
Phaser.Rectangle.union = function (a, b, out) {
|
||||
|
||||
Reference in New Issue
Block a user