Skip to content

Commit

Permalink
Fix max overlap check in overrides.js
Browse files Browse the repository at this point in the history
  • Loading branch information
voithos committed Dec 26, 2013
1 parent e452e68 commit 1556f8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ function create() {
cfg.FLOATING_TILES.forEach(function(tile) {
var t = tileset.getTile(tile);
t.setCollision(false, false, true, false);
t.disableMaxOverlapCheck = false;
t.enableMaxOverlapCheck = true;
});
cfg.UPWARD_SLOPE_TILES.forEach(function(tile) {
var t = tileset.getTile(tile);
t.setCollision(false, false, true, false);
t.disableMaxOverlapCheck = true;
t.enableMaxOverlapCheck = false;
});
cfg.DOWNWARD_SLOPE_TILES.forEach(function(tile) {
var t = tileset.getTile(tile);
t.setCollision(false, false, true, false);
t.disableMaxOverlapCheck = true;
t.enableMaxOverlapCheck = false;
});
cfg.BACKGROUND_TILES.forEach(function(tile) {
tileset.setCollision(tile, false, false, false, false);
Expand Down
8 changes: 4 additions & 4 deletions src/overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (typeof Phaser !== 'undefined') {
// Moving left
this._overlap = tile.right - body.hullX.x;

if ((this._overlap > this._maxOverlap && !tile.tile.disableMaxOverlapCheck) || body.allowCollision.left === false || tile.tile.collideRight === false)
if ((tile.tile.enableMaxOverlapCheck && this._overlap > this._maxOverlap) || body.allowCollision.left === false || tile.tile.collideRight === false)
// if (body.allowCollision.left === false || tile.tile.collideRight === false)
{
this._overlap = 0;
Expand All @@ -40,7 +40,7 @@ if (typeof Phaser !== 'undefined') {
// Moving right
this._overlap = body.hullX.right - tile.x;

if ((this._overlap > this._maxOverlap && !tile.tile.disableMaxOverlapCheck) || body.allowCollision.right === false || tile.tile.collideLeft === false)
if ((tile.tile.enableMaxOverlapCheck && this._overlap > this._maxOverlap) || body.allowCollision.right === false || tile.tile.collideLeft === false)
// if (body.allowCollision.right === false || tile.tile.collideLeft === false)
{
this._overlap = 0;
Expand Down Expand Up @@ -104,7 +104,7 @@ if (typeof Phaser !== 'undefined') {
// Moving up
this._overlap = tile.bottom - body.hullY.y;

if ((this._overlap > this._maxOverlap && !tile.tile.disableMaxOverlapCheck) || body.allowCollision.up === false || tile.tile.collideDown === false)
if ((tile.tile.enableMaxOverlapCheck && this._overlap > this._maxOverlap) || body.allowCollision.up === false || tile.tile.collideDown === false)
// if (body.allowCollision.up === false || tile.tile.collideDown === false)
{
this._overlap = 0;
Expand All @@ -119,7 +119,7 @@ if (typeof Phaser !== 'undefined') {
// Moving down
this._overlap = body.hullY.bottom - tile.y;

if ((this._overlap > this._maxOverlap && !tile.tile.disableMaxOverlapCheck) || body.allowCollision.down === false || tile.tile.collideUp === false)
if ((tile.tile.enableMaxOverlapCheck && this._overlap > this._maxOverlap) || body.allowCollision.down === false || tile.tile.collideUp === false)
// if (body.allowCollision.down === false || tile.tile.collideUp === false)
{
this._overlap = 0;
Expand Down

0 comments on commit 1556f8b

Please sign in to comment.