Skip to content

Commit 510353f

Browse files
committed
Fix row/col count formula.
This fixes the rendering issue for tilesets with margin/spacing as described in phaserjs#1641.
1 parent 41396d5 commit 510353f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/tilemap/Tileset.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ Phaser.Tileset.prototype = {
214214
updateTileData: function (imageWidth, imageHeight) {
215215

216216
// May be fractional values
217-
var rowCount = (imageHeight - this.tileMargin) / (this.tileHeight + this.tileSpacing);
218-
var colCount = (imageWidth - this.tileMargin) / (this.tileWidth + this.tileSpacing);
217+
var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing);
218+
var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing);
219219

220220
if (rowCount % 1 !== 0 || colCount % 1 !== 0)
221221
{

0 commit comments

Comments
 (0)