Skip to content

Commit 1773d0c

Browse files
committed
Fix sub-pixel jitter after tile separation
1 parent a996562 commit 1773d0c

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/physics/arcade/tilemap/ProcessTileSeparationX.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ var ProcessTileSeparationX = function (body, x)
2727
}
2828

2929
body.position.x -= x;
30+
31+
// Snap to integer to avoid sub-pixel jitter (tiles are always at whole coords)
32+
body.position.x = Math.round(body.position.x);
33+
3034
body.updateCenter();
3135

3236
if (body.bounce.x === 0)

src/physics/arcade/tilemap/ProcessTileSeparationY.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ var ProcessTileSeparationY = function (body, y)
2727
}
2828

2929
body.position.y -= y;
30+
31+
// Snap to integer to avoid sub-pixel jitter (tiles are always at whole coords)
32+
body.position.y = Math.round(body.position.y);
33+
3034
body.updateCenter();
3135

3236
if (body.bounce.y === 0)

0 commit comments

Comments
 (0)