Skip to content

Commit 23f077a

Browse files
committed
copy tile properties to tiles when parsing map
1 parent 118ea6f commit 23f077a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

src/tilemap/TilemapParser.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,41 @@ Phaser.TilemapParser = {
490490

491491
}
492492

493+
// assign tile properties
494+
495+
var i,j,k;
496+
var layer, tile, sid, set;
497+
498+
// go through each of the map layers
499+
for (i = 0; i < map.layers.length; i++)
500+
{
501+
layer = map.layers[i];
502+
503+
// rows of tiles
504+
for (j = 0; j < layer.data.length; j++)
505+
{
506+
row = layer.data[j];
507+
508+
// individual tiles
509+
for (k = 0; k < row.length; k++)
510+
{
511+
tile = row[k];
512+
513+
if(tile.index < 0) { continue; }
514+
515+
// find the relevant tileset
516+
sid = map.tiles[tile.index][2];
517+
set = map.tilesets[sid];
518+
519+
// if that tile type has any properties, add them to the tile object
520+
if(set.tileProperties && set.tileProperties[tile.index - set.firstgid]) {
521+
tile.properties = set.tileProperties[tile.index - set.firstgid];
522+
}
523+
}
524+
}
525+
}
526+
527+
493528
return map;
494529

495530
}

0 commit comments

Comments
 (0)