Skip to content

Commit 8297473

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents e601f40 + 5241798 commit 8297473

5 files changed

Lines changed: 20 additions & 18 deletions

File tree

src/physics/arcade/World.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ var World = new Class({
4848

4949
this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4);
5050

51+
this.TILE_BIAS = GetValue(config, 'tileBias', 16);
52+
5153
this.forceX = GetValue(config, 'forceX', false);
5254

5355
this.isPaused = GetValue(config, 'isPaused', false);

src/physics/arcade/inc/CollideSpriteVsTilemapLayer.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ var ProcessTileCallbacks = require('./tilemap/ProcessTileCallbacks');
44

55
var CollideSpriteVsTilemapLayer = function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)
66
{
7-
if (!sprite.body.enable)
7+
var body = sprite.body;
8+
9+
if (!body.enable)
810
{
911
return false;
1012
}
1113

1214
var mapData = tilemapLayer.getTilesWithinWorldXY(
13-
sprite.body.position.x, sprite.body.position.y,
14-
sprite.body.width, sprite.body.height
15+
body.position.x, body.position.y,
16+
body.width, body.height
1517
);
1618

1719
if (mapData.length === 0)
@@ -30,10 +32,10 @@ var CollideSpriteVsTilemapLayer = function (sprite, tilemapLayer, collideCallbac
3032
tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX;
3133
tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY;
3234

33-
if (TileIntersectsBody(tileWorldRect, sprite.body)
35+
if (TileIntersectsBody(tileWorldRect, body)
3436
&& (!processCallback || processCallback.call(callbackContext, sprite, tile))
3537
&& ProcessTileCallbacks(tile)
36-
&& (overlapOnly || SeparateTile(i, sprite.body, tile, tileWorldRect, tilemapLayer)))
38+
&& (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS)))
3739
{
3840
this._total++;
3941

src/physics/arcade/inc/tilemap/SeparateTile.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var TileIntersectsBody = require('./TileIntersectsBody');
1010
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against.
1111
* @return {boolean} Returns true if the body was separated, otherwise false.
1212
*/
13-
var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer)
13+
var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias)
1414
{
1515
var tileLeft = tileWorldRect.left;
1616
var tileTop = tileWorldRect.top;
@@ -55,7 +55,7 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer)
5555
{
5656
if (faceHorizontal)
5757
{
58-
ox = TileCheckX(body, tile, tilemapLayer);
58+
ox = TileCheckX(body, tile, tilemapLayer, tileBias);
5959

6060
// That's horizontal done, check if we still intersects? If not then we can return now
6161
if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body))
@@ -66,14 +66,14 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer)
6666

6767
if (faceVertical)
6868
{
69-
oy = TileCheckY(body, tile, tilemapLayer);
69+
oy = TileCheckY(body, tile, tilemapLayer, tileBias);
7070
}
7171
}
7272
else
7373
{
7474
if (faceVertical)
7575
{
76-
oy = TileCheckY(body, tile, tilemapLayer);
76+
oy = TileCheckY(body, tile, tilemapLayer, tileBias);
7777

7878
// That's vertical done, check if we still intersects? If not then we can return now
7979
if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body))
@@ -84,7 +84,7 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer)
8484

8585
if (faceHorizontal)
8686
{
87-
ox = TileCheckX(body, tile, tilemapLayer);
87+
ox = TileCheckX(body, tile, tilemapLayer, tileBias);
8888
}
8989
}
9090

src/physics/arcade/inc/tilemap/TileCheckX.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var TILE_BIAS = 16;
21
var ProcessTileSeparationX = require('./ProcessTileSeparationX');
32

43
/**
@@ -11,7 +10,7 @@ var ProcessTileSeparationX = require('./ProcessTileSeparationX');
1110
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against.
1211
* @return {number} The amount of separation that occurred.
1312
*/
14-
var TileCheckX = function (body, tile, tilemapLayer)
13+
var TileCheckX = function (body, tile, tilemapLayer, tileBias)
1514
{
1615
var ox = 0;
1716
var tileLeft = tilemapLayer.tileToWorldX(tile.x);
@@ -25,7 +24,7 @@ var TileCheckX = function (body, tile, tilemapLayer)
2524
{
2625
ox = body.x - tileRight;
2726

28-
if (ox < -TILE_BIAS)
27+
if (ox < -tileBias)
2928
{
3029
ox = 0;
3130
}
@@ -38,7 +37,7 @@ var TileCheckX = function (body, tile, tilemapLayer)
3837
{
3938
ox = body.right - tileLeft;
4039

41-
if (ox > TILE_BIAS)
40+
if (ox > tileBias)
4241
{
4342
ox = 0;
4443
}

src/physics/arcade/inc/tilemap/TileCheckY.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var TILE_BIAS = 16;
21
var ProcessTileSeparationY = require('./ProcessTileSeparationY');
32

43
/**
@@ -11,7 +10,7 @@ var ProcessTileSeparationY = require('./ProcessTileSeparationY');
1110
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against.
1211
* @return {number} The amount of separation that occurred.
1312
*/
14-
var TileCheckY = function (body, tile, tilemapLayer)
13+
var TileCheckY = function (body, tile, tilemapLayer, tileBias)
1514
{
1615
var oy = 0;
1716
var tileTop = tilemapLayer.tileToWorldX(tile.y);
@@ -25,7 +24,7 @@ var TileCheckY = function (body, tile, tilemapLayer)
2524
{
2625
oy = body.y - tileBottom;
2726

28-
if (oy < -TILE_BIAS)
27+
if (oy < -tileBias)
2928
{
3029
oy = 0;
3130
}
@@ -38,7 +37,7 @@ var TileCheckY = function (body, tile, tilemapLayer)
3837
{
3938
oy = body.bottom - tileTop;
4039

41-
if (oy > TILE_BIAS)
40+
if (oy > tileBias)
4241
{
4342
oy = 0;
4443
}

0 commit comments

Comments
 (0)