Tidying up source code for release. Also refactored World to use a Group instance, rather tha duplicate functions.

This commit is contained in:
Richard Davey
2013-09-11 13:21:07 +01:00
parent 87858d6bbf
commit f260108433
25 changed files with 278 additions and 487 deletions
+22 -30
View File
@@ -205,13 +205,12 @@ Object.defineProperty(Phaser.Circle.prototype, "diameter", {
* @param {Number} The diameter of the circle.
**/
set: function (value) {
if(value > 0) {
if (value > 0) {
this._diameter = value;
this._radius = value * 0.5;
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Circle.prototype, "radius", {
@@ -231,13 +230,12 @@ Object.defineProperty(Phaser.Circle.prototype, "radius", {
* @param {Number} The radius of the circle.
**/
set: function (value) {
if(value > 0) {
if (value > 0) {
this._radius = value;
this._diameter = value * 2;
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Circle.prototype, "left", {
@@ -257,15 +255,14 @@ Object.defineProperty(Phaser.Circle.prototype, "left", {
* @param {Number} The value to adjust the position of the leftmost point of the circle by.
**/
set: function (value) {
if(value > this.x) {
if (value > this.x) {
this._radius = 0;
this._diameter = 0;
} else {
this.radius = this.x - value;
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Circle.prototype, "right", {
@@ -285,15 +282,14 @@ Object.defineProperty(Phaser.Circle.prototype, "right", {
* @param {Number} The amount to adjust the diameter of the circle by.
**/
set: function (value) {
if(value < this.x) {
if (value < this.x) {
this._radius = 0;
this._diameter = 0;
} else {
this.radius = value - this.x;
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Circle.prototype, "top", {
@@ -313,15 +309,14 @@ Object.defineProperty(Phaser.Circle.prototype, "top", {
* @param {Number} The amount to adjust the height of the circle by.
**/
set: function (value) {
if(value > this.y) {
if (value > this.y) {
this._radius = 0;
this._diameter = 0;
} else {
this.radius = this.y - value;
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Circle.prototype, "bottom", {
@@ -348,9 +343,8 @@ Object.defineProperty(Phaser.Circle.prototype, "bottom", {
} else {
this.radius = value - this.y;
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Circle.prototype, "area", {
@@ -361,14 +355,13 @@ Object.defineProperty(Phaser.Circle.prototype, "area", {
* @return {Number} This area of this circle.
**/
get: function () {
if(this._radius > 0) {
if (this._radius > 0) {
return Math.PI * this._radius * this._radius;
} else {
return 0;
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Circle.prototype, "empty", {
@@ -389,9 +382,8 @@ Object.defineProperty(Phaser.Circle.prototype, "empty", {
**/
set: function (value) {
this.setTo(0, 0, 0);
},
enumerable: true,
configurable: true
}
});
// Statics
+29 -42
View File
@@ -266,9 +266,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", {
**/
get: function () {
return Math.round(this.width / 2);
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
@@ -280,9 +279,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
**/
get: function () {
return Math.round(this.height / 2);
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "bottom", {
@@ -302,14 +300,13 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottom", {
* @param {Number} value
**/
set: function (value) {
if(value <= this.y) {
if (value <= this.y) {
this.height = 0;
} else {
this.height = (this.y - value);
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
@@ -330,9 +327,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
set: function (value) {
this.right = value.x;
this.bottom = value.y;
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "left", {
@@ -359,9 +355,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "left", {
this.width = this.right - value;
}
this.x = value;
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "right", {
@@ -383,14 +378,13 @@ Object.defineProperty(Phaser.Rectangle.prototype, "right", {
* @param {Number} value
**/
set: function (value) {
if(value <= this.x) {
if (value <= this.x) {
this.width = 0;
} else {
this.width = this.x + value;
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
@@ -402,9 +396,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
**/
get: function () {
return this.width * this.height;
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
@@ -416,9 +409,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
**/
get: function () {
return (this.width * 2) + (this.height * 2);
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
@@ -439,9 +431,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
**/
set: function (value) {
this.x = value - this.halfWidth;
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
@@ -462,9 +453,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
**/
set: function (value) {
this.y = value - this.halfHeight;
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "top", {
@@ -486,15 +476,14 @@ Object.defineProperty(Phaser.Rectangle.prototype, "top", {
* @param {Number} value
**/
set: function (value) {
if(value >= this.bottom) {
if (value >= this.bottom) {
this.height = 0;
this.y = value;
} else {
this.height = (this.bottom - value);
}
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
@@ -515,9 +504,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
set: function (value) {
this.x = value.x;
this.y = value.y;
},
enumerable: true,
configurable: true
}
});
Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
@@ -538,9 +526,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
**/
set: function (value) {
this.setTo(0, 0, 0, 0);
},
enumerable: true,
configurable: true
}
});
// Statics