Small fix: use base tile size for tile <-> XY transforms. This only matters for maps with different size tiles.

This commit is contained in:
Michael Hadley 2017-12-01 13:25:48 -06:00
parent 37767ebde1
commit a8fdcbc56b
6 changed files with 12 additions and 7 deletions

View file

@ -1061,9 +1061,12 @@ var Tilemap = new Class({
this.widthInPixels = this.width * tileWidth;
this.heightInPixels = this.height * tileHeight;
// Update the base tile size on all tiles
// Update the base tile size on all layers & tiles
for (var i = 0; i < this.layers.length; i++)
{
this.layers[i].baseWidth = tileWidth;
this.layers[i].baseHeight = tileHeight;
var mapData = this.layers[i].data;
var mapWidth = this.layers[i].width;
var mapHeight = this.layers[i].height;

View file

@ -9,7 +9,7 @@
*/
var TileToWorldX = function (tileX, camera, layer)
{
var tileWidth = layer.tileWidth;
var tileWidth = layer.baseTileWidth;
var tilemapLayer = layer.tilemapLayer;
var layerWorldX = 0;

View file

@ -9,7 +9,7 @@
*/
var TileToWorldY = function (tileY, camera, layer)
{
var tileHeight = layer.tileHeight;
var tileHeight = layer.baseTileHeight;
var tilemapLayer = layer.tilemapLayer;
var layerWorldY = 0;

View file

@ -13,7 +13,7 @@ var WorldToTileX = function (worldX, snapToFloor, camera, layer)
{
if (snapToFloor === undefined) { snapToFloor = true; }
var tileWidth = layer.tileWidth;
var tileWidth = layer.baseTileWidth;
var tilemapLayer = layer.tilemapLayer;
if (tilemapLayer)

View file

@ -13,7 +13,7 @@ var WorldToTileY = function (worldY, snapToFloor, camera, layer)
{
if (snapToFloor === undefined) { snapToFloor = true; }
var tileHeight = layer.tileHeight;
var tileHeight = layer.baseTileHeight;
var tilemapLayer = layer.tilemapLayer;
if (tilemapLayer)

View file

@ -26,8 +26,10 @@ var LayerData = new Class({
this.height = GetFastValue(config, 'height', 0);
this.tileWidth = GetFastValue(config, 'tileWidth', 0);
this.tileHeight = GetFastValue(config, 'tileHeight', 0);
this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.tileWidth);
this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.tileHeight);
this.baseTileWidth = GetFastValue(config, 'baseTileWidth', this.tileWidth);
this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight);
this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth);
this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.baseTileHeight);
this.alpha = GetFastValue(config, 'alpha', 1);
this.visible = GetFastValue(config, 'visible', true);
this.properties = GetFastValue(config, 'properties', {});