Skip to content

Commit 816a80f

Browse files
committed
If Body.customSeparateX or customSeparateY is true then the Body will no longer be automatically separated from a **Tilemap** collision or exchange any velocity. The amount of pixels that the Body has intersected the tile is available in Body.overlapX and overlapY, so you can use these values to perform your own separation in your collision callback (phaserjs#992)
1 parent 4489a12 commit 816a80f

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Thanks to @pnstickne for vast majority of this update.
116116
* Device.touch checks if `window.navigator.maxTouchPoints` is `>= 1` rather than > 1, which now allows touch events to work properly in Chrome mobile emulation.
117117
* Loader.XDomainRequest wasn't used for atlas json loading. It has now been moved to the `xhrLoad` method to ensure it's used for all request if required (thanks @draconisNoctis #1601)
118118
* Loader.reset has a new optional 2nd parameter `clearEvents` which if set to `true` (the default is false) will reset all event listeners bound to the Loader.
119+
* If `Body.customSeparateX` or `customSeparateY` is `true` then the Body will no longer be automatically separated from a **Tilemap** collision or exchange any velocity. The amount of pixels that the Body has intersected the tile is available in `Body.overlapX` and `overlapY`, so you can use these values to perform your own separation in your collision callback (#992)
119120

120121
### Bug Fixes
121122

src/physics/arcade/World.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,14 @@ Phaser.Physics.Arcade.prototype = {
12841284

12851285
if (ox !== 0)
12861286
{
1287-
this.processTileSeparationX(body, ox);
1287+
if (body.customSeparateX)
1288+
{
1289+
body.overlapX = ox;
1290+
}
1291+
else
1292+
{
1293+
this.processTileSeparationX(body, ox);
1294+
}
12881295
}
12891296

12901297
return ox;
@@ -1333,7 +1340,14 @@ Phaser.Physics.Arcade.prototype = {
13331340

13341341
if (oy !== 0)
13351342
{
1336-
this.processTileSeparationY(body, oy);
1343+
if (body.customSeparateY)
1344+
{
1345+
body.overlapY = oy;
1346+
}
1347+
else
1348+
{
1349+
this.processTileSeparationY(body, oy);
1350+
}
13371351
}
13381352

13391353
return oy;
@@ -1347,7 +1361,6 @@ Phaser.Physics.Arcade.prototype = {
13471361
* @method Phaser.Physics.Arcade#processTileSeparationX
13481362
* @param {Phaser.Physics.Arcade.Body} body - The Body object to separate.
13491363
* @param {number} x - The x separation amount.
1350-
* @return {boolean} Returns true as a pass-thru to the separateTile method.
13511364
*/
13521365
processTileSeparationX: function (body, x) {
13531366

0 commit comments

Comments
 (0)