Fixed Rectangle intersection issue and tilemap collision is working again. Win!

This commit is contained in:
photonstorm
2013-10-15 15:24:07 +01:00
parent f3ea68aad3
commit fd5eeb9088
5 changed files with 104 additions and 74 deletions
+6 -4
View File
@@ -618,14 +618,16 @@ Phaser.Rectangle.intersection = function (a, b, out) {
* @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
* @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false.
*/
Phaser.Rectangle.intersects = function (a, b, tolerance) {
Phaser.Rectangle.intersects = function (a, b) {
tolerance = tolerance || 0;
return (a.x < b.right && b.x < a.right && a.y < b.bottom && b.y < a.bottom);
return !(a.x > b.right + tolerance || a.right < b.x - tolerance || a.y > b.bottom + tolerance || a.bottom < b.y - tolerance);
// return (a.x <= b.right && b.x <= a.right && a.y <= b.bottom && b.y <= a.bottom);
// return (a.left <= b.right && b.left <= a.right && a.top <= b.bottom && b.top <= a.bottom);
// return !(a.x > b.right + tolerance || a.right < b.x - tolerance || a.y > b.bottom + tolerance || a.bottom < b.y - tolerance);
};