Fix IsometricWorldToTileXY result

IsometricWorldToTileXY returns a tile that is offset by (-0.5, 0.5)
tiles from the expected location.  This fixes the function so that
Tile => World => Tile conversion returns the same value.
This commit is contained in:
Ben Randall 2021-01-28 12:25:51 -05:00
parent 1ebfdef9e8
commit 40ff85bdc5

View file

@ -50,8 +50,6 @@ var IsometricWorldToTileXY = function (worldX, worldY, snapToFloor, point, camer
tileWidth *= tilemapLayer.scaleX;
}
worldX -= tileWidth / 2;
var x = (snapToFloor) ? Math.floor((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2) : ((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2);
var y = (snapToFloor) ? Math.floor((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2) : ((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2);