Skip to content

Commit a8fdcbc

Browse files
committed
Small fix: use base tile size for tile <-> XY transforms. This only matters for maps with different size tiles.
1 parent 37767eb commit a8fdcbc

6 files changed

Lines changed: 12 additions & 7 deletions

File tree

v3/src/gameobjects/tilemap/Tilemap.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,12 @@ var Tilemap = new Class({
10611061
this.widthInPixels = this.width * tileWidth;
10621062
this.heightInPixels = this.height * tileHeight;
10631063

1064-
// Update the base tile size on all tiles
1064+
// Update the base tile size on all layers & tiles
10651065
for (var i = 0; i < this.layers.length; i++)
10661066
{
1067+
this.layers[i].baseWidth = tileWidth;
1068+
this.layers[i].baseHeight = tileHeight;
1069+
10671070
var mapData = this.layers[i].data;
10681071
var mapWidth = this.layers[i].width;
10691072
var mapHeight = this.layers[i].height;

v3/src/gameobjects/tilemap/components/TileToWorldX.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
var TileToWorldX = function (tileX, camera, layer)
1111
{
12-
var tileWidth = layer.tileWidth;
12+
var tileWidth = layer.baseTileWidth;
1313
var tilemapLayer = layer.tilemapLayer;
1414
var layerWorldX = 0;
1515

v3/src/gameobjects/tilemap/components/TileToWorldY.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
var TileToWorldY = function (tileY, camera, layer)
1111
{
12-
var tileHeight = layer.tileHeight;
12+
var tileHeight = layer.baseTileHeight;
1313
var tilemapLayer = layer.tilemapLayer;
1414
var layerWorldY = 0;
1515

v3/src/gameobjects/tilemap/components/WorldToTileX.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var WorldToTileX = function (worldX, snapToFloor, camera, layer)
1313
{
1414
if (snapToFloor === undefined) { snapToFloor = true; }
1515

16-
var tileWidth = layer.tileWidth;
16+
var tileWidth = layer.baseTileWidth;
1717
var tilemapLayer = layer.tilemapLayer;
1818

1919
if (tilemapLayer)

v3/src/gameobjects/tilemap/components/WorldToTileY.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var WorldToTileY = function (worldY, snapToFloor, camera, layer)
1313
{
1414
if (snapToFloor === undefined) { snapToFloor = true; }
1515

16-
var tileHeight = layer.tileHeight;
16+
var tileHeight = layer.baseTileHeight;
1717
var tilemapLayer = layer.tilemapLayer;
1818

1919
if (tilemapLayer)

v3/src/gameobjects/tilemap/mapdata/LayerData.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ var LayerData = new Class({
2626
this.height = GetFastValue(config, 'height', 0);
2727
this.tileWidth = GetFastValue(config, 'tileWidth', 0);
2828
this.tileHeight = GetFastValue(config, 'tileHeight', 0);
29-
this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.tileWidth);
30-
this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.tileHeight);
29+
this.baseTileWidth = GetFastValue(config, 'baseTileWidth', this.tileWidth);
30+
this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight);
31+
this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth);
32+
this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.baseTileHeight);
3133
this.alpha = GetFastValue(config, 'alpha', 1);
3234
this.visible = GetFastValue(config, 'visible', true);
3335
this.properties = GetFastValue(config, 'properties', {});

0 commit comments

Comments
 (0)