mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
copy tile properties to tiles when parsing map
This commit is contained in:
parent
118ea6f84a
commit
23f077a4e8
1 changed files with 35 additions and 0 deletions
|
@ -490,6 +490,41 @@ Phaser.TilemapParser = {
|
|||
|
||||
}
|
||||
|
||||
// assign tile properties
|
||||
|
||||
var i,j,k;
|
||||
var layer, tile, sid, set;
|
||||
|
||||
// go through each of the map layers
|
||||
for (i = 0; i < map.layers.length; i++)
|
||||
{
|
||||
layer = map.layers[i];
|
||||
|
||||
// rows of tiles
|
||||
for (j = 0; j < layer.data.length; j++)
|
||||
{
|
||||
row = layer.data[j];
|
||||
|
||||
// individual tiles
|
||||
for (k = 0; k < row.length; k++)
|
||||
{
|
||||
tile = row[k];
|
||||
|
||||
if(tile.index < 0) { continue; }
|
||||
|
||||
// find the relevant tileset
|
||||
sid = map.tiles[tile.index][2];
|
||||
set = map.tilesets[sid];
|
||||
|
||||
// if that tile type has any properties, add them to the tile object
|
||||
if(set.tileProperties && set.tileProperties[tile.index - set.firstgid]) {
|
||||
tile.properties = set.tileProperties[tile.index - set.firstgid];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return map;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue