Skip to content

Commit 5b10c07

Browse files
committed
ArcadePhysics.Body.checkWorldBounds would incorrectly report as being on the World bounds if the blocked.none flag had been toggled elsewhere in the Body. It now only sets if it toggles a new internal flag
1 parent d0c40b6 commit 5b10c07

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Bug Fixes
1010

1111
* `SpineCanvasPlugin.shutdown` would try to dispose of the `sceneRenderer`, but the property isn't set for Canvas.
12+
* `ArcadePhysics.Body.checkWorldBounds` would incorrectly report as being on the World bounds if the `blocked.none` flag had been toggled elsewhere in the Body. It now only sets if it toggles a new internal flag (thanks Pablo)
1213

1314
## Version 3.19.0 - Naofumi - 8th August 2019
1415

src/physics/arcade/Body.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,37 +1060,44 @@ var Body = new Class({
10601060
var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x;
10611061
var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y;
10621062

1063+
var wasSet = false;
1064+
10631065
if (pos.x < bounds.x && check.left)
10641066
{
10651067
pos.x = bounds.x;
10661068
this.velocity.x *= bx;
10671069
this.blocked.left = true;
1068-
this.blocked.none = false;
1070+
wasSet = true;
10691071
}
10701072
else if (this.right > bounds.right && check.right)
10711073
{
10721074
pos.x = bounds.right - this.width;
10731075
this.velocity.x *= bx;
10741076
this.blocked.right = true;
1075-
this.blocked.none = false;
1077+
wasSet = true;
10761078
}
10771079

10781080
if (pos.y < bounds.y && check.up)
10791081
{
10801082
pos.y = bounds.y;
10811083
this.velocity.y *= by;
10821084
this.blocked.up = true;
1083-
this.blocked.none = false;
1085+
wasSet = true;
10841086
}
10851087
else if (this.bottom > bounds.bottom && check.down)
10861088
{
10871089
pos.y = bounds.bottom - this.height;
10881090
this.velocity.y *= by;
10891091
this.blocked.down = true;
1092+
wasSet = true;
1093+
}
1094+
1095+
if (wasSet)
1096+
{
10901097
this.blocked.none = false;
10911098
}
10921099

1093-
return !this.blocked.none;
1100+
return wasSet;
10941101
},
10951102

10961103
/**

0 commit comments

Comments
 (0)