fix PutTileAt tile size with releated tileset width and height, releated bug #5647
This commit is contained in:
Richard Davey 2021-09-22 11:10:03 +01:00 committed by GitHub
commit 7434769faf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@ var Tile = require('../Tile');
var IsInLayerBounds = require('./IsInLayerBounds');
var CalculateFacesAt = require('./CalculateFacesAt');
var SetTileCollision = require('./SetTileCollision');
var BuildTilesetIndex = require('../parsers/tiled/BuildTilesetIndex');
/**
* Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index
@ -65,6 +66,16 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
var newTile = layer.data[tileY][tileX];
var collides = layer.collideIndexes.indexOf(newTile.index) !== -1;
// Copy properties from tileset to tiles.
var tiles = BuildTilesetIndex(layer.tilemapLayer.tilemap);
var index = tile instanceof Tile ? tile.index : tile;
var sid = tiles[index][2];
var set = layer.tilemapLayer.tileset[sid];
newTile.width = set.tileWidth;
newTile.height = set.tileHeight;
SetTileCollision(newTile, collides);
// Recalculate faces only if the colliding flag at (tileX, tileY) has changed