Skip to content

Commit 8c6fec0

Browse files
committed
Apply "half pixel correction" to the source coordinates for tiles when drawing with WebGL.
1 parent 8832680 commit 8c6fec0

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/tilemap/Tileset.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ Phaser.Tileset.prototype = {
172172

173173
if (coordIndex >= 0 && (coordIndex + 1) < this.drawCoords.length)
174174
{
175-
var sx = this.drawCoords[coordIndex];
176-
var sy = this.drawCoords[coordIndex + 1];
177-
var sw = this.tileWidth;
178-
var sh = this.tileHeight;
175+
// apply "half-pixel correction" to avoid edge bleeding as much as possible
176+
var sx = this.drawCoords[coordIndex] + 0.5;
177+
var sy = this.drawCoords[coordIndex + 1] + 0.5;
178+
var sw = this.tileWidth - 1.0;
179+
var sh = this.tileHeight - 1.0;
179180
var fd = 0;
180181

181182
if (flippedVal)

0 commit comments

Comments
 (0)