mirror of
https://github.com/wassname/phaser.git
synced 2026-09-11 12:31:29 +08:00
Sorted out the bounds for when sprites are in trimmed texture atlases to stop the physics checks going insane. Also bundled in Advanced Physics lib, although not hooked up yet.
This commit is contained in:
+50
-4
@@ -11,10 +11,10 @@
|
||||
**/
|
||||
Phaser.Rectangle = function (x, y, width, height) {
|
||||
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
if (typeof width === "undefined") { width = 0; }
|
||||
if (typeof height === "undefined") { height = 0; }
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
width = width || 0;
|
||||
height = height || 0;
|
||||
|
||||
/**
|
||||
* @property x
|
||||
@@ -449,6 +449,52 @@ Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
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;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
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;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "top", {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user