mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Prevent objects from sinking into tilemaps at low frame rates.
Because `blocked` would be set by the first collision, repeated steps would then skip it, and allow gravity or acceleration to ignore tiles in that direction for those steps.
This commit is contained in:
parent
24f0187028
commit
fd0dd79417
2 changed files with 4 additions and 4 deletions
|
@ -39,7 +39,7 @@ var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias, isLayer)
|
||||||
collideRight = true;
|
collideRight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.deltaX() < 0 && !body.blocked.left && collideRight && body.checkCollision.left)
|
if (body.deltaX() < 0 && collideRight && body.checkCollision.left)
|
||||||
{
|
{
|
||||||
// Body is moving LEFT
|
// Body is moving LEFT
|
||||||
if (faceRight && body.x < tileRight)
|
if (faceRight && body.x < tileRight)
|
||||||
|
@ -52,7 +52,7 @@ var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias, isLayer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (body.deltaX() > 0 && !body.blocked.right && collideLeft && body.checkCollision.right)
|
else if (body.deltaX() > 0 && collideLeft && body.checkCollision.right)
|
||||||
{
|
{
|
||||||
// Body is moving RIGHT
|
// Body is moving RIGHT
|
||||||
if (faceLeft && body.right > tileLeft)
|
if (faceLeft && body.right > tileLeft)
|
||||||
|
|
|
@ -39,7 +39,7 @@ var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias, isLayer)
|
||||||
collideDown = true;
|
collideDown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.deltaY() < 0 && !body.blocked.up && collideDown && body.checkCollision.up)
|
if (body.deltaY() < 0 && collideDown && body.checkCollision.up)
|
||||||
{
|
{
|
||||||
// Body is moving UP
|
// Body is moving UP
|
||||||
if (faceBottom && body.y < tileBottom)
|
if (faceBottom && body.y < tileBottom)
|
||||||
|
@ -52,7 +52,7 @@ var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias, isLayer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (body.deltaY() > 0 && !body.blocked.down && collideUp && body.checkCollision.down)
|
else if (body.deltaY() > 0 && collideUp && body.checkCollision.down)
|
||||||
{
|
{
|
||||||
// Body is moving DOWN
|
// Body is moving DOWN
|
||||||
if (faceTop && body.bottom > tileTop)
|
if (faceTop && body.bottom > tileTop)
|
||||||
|
|
Loading…
Reference in a new issue