Skip to content

Commit b9ac0d5

Browse files
committed
Fixed Tile callback check in Arcade Physics (fix phaserjs#562)
1 parent ec2275e commit b9ac0d5

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Bug Fixes
6363
* Fixed the IE11 version check (fixes #579)
6464
* Ninja world collision to check right and bottom bounds (thanks dreadhorse, fix #571)
6565
* Group enableBody parameter was incorrectly assigned to the debug var (thanks BurnedToast, fix #565)
66+
* Fixed Tile callback check in Arcade Physics (fix #562)
6667

6768

6869
Version 2.0.0 - "Aes Sedai" - March 13th 2014

src/physics/arcade/World.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ Phaser.Physics.Arcade.prototype = {
956956
}
957957

958958
// They overlap. Any custom callbacks?
959+
/*
959960
if (tile.collisionCallback || tile.layer.callbacks[tile.index])
960961
{
961962
// A local callback takes priority over a global callback.
@@ -970,6 +971,17 @@ Phaser.Physics.Arcade.prototype = {
970971
return false;
971972
}
972973
}
974+
*/
975+
976+
if (tile.collisionCallback)
977+
{
978+
// A local callback takes priority over a global callback.
979+
if (tile.collisionCallbackk && tile.collisionCallback.call(tile.collisionCallbackContext, body.sprite, tile) === false)
980+
{
981+
// Is there a tile specific collision callback? If it returns true then we can carry on, otherwise we should abort.
982+
return false;
983+
}
984+
}
973985

974986
var ox = 0;
975987
var oy = 0;

src/tilemap/Tile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ Phaser.Tile.prototype = {
271271
if (collides && faces)
272272
{
273273
// Does this tile have any collide flags OR interesting face?
274-
return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.faceTop || this.faceBottom || this.faceLeft || this.faceRight || this.collisionCallback || this.layer.callbacks[this.index]);
274+
return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.faceTop || this.faceBottom || this.faceLeft || this.faceRight || this.collisionCallback);
275275
}
276276
else if (collides)
277277
{
@@ -335,7 +335,7 @@ Object.defineProperty(Phaser.Tile.prototype, "collides", {
335335
Object.defineProperty(Phaser.Tile.prototype, "canCollide", {
336336

337337
get: function () {
338-
return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback || this.layer.callbacks[this.index]);
338+
return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback);
339339
}
340340

341341
});

src/tilemap/Tilemap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ Phaser.Tilemap.prototype = {
318318
countX = 0;
319319
countY++;
320320

321-
if (countY === set.rows)
321+
if (countY === newSet.rows)
322322
{
323323
break;
324324
}

0 commit comments

Comments
 (0)