Skip to content

Commit

Permalink
parse animation data in XML, fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
englercj committed Oct 17, 2014
1 parent e4e846e commit e577d04
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/tiled/TilemapParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ var TilemapParser = {
}
}

//add .tiles if multi-image set
//add .tiles if there are tile-specific properties
for(var t = 0; t < tiles.length; ++t) {
var tile = tiles[t],
id = tile.attributes.getNamedItem('id').value,
Expand Down Expand Up @@ -297,6 +297,22 @@ var TilemapParser = {
tileset.tileproperties[id][tileprop.attributes.getNamedItem('name').value] = tileprop.attributes.getNamedItem('value').value;
}
}

//add all the tile animations
var tileanims = tile.getElementsByTagName('animation');
if (tileanims.length) {
tileset.tiles[id].animation = [];
tileanims = tileanims[0].getElementsByTagName('frame');
for(var tn = 0; tn < tileanims.length; ++tn) {
var tileanim = tileanims[tn].attributes,
animObj = {};
for (var tna = 0; tna < tileanim.length; ++tna) {
animObj[tileanim[tna].name] = tileanim[tna].value;
}

tileset.tiles[id].animation.push(animObj);
}
}
}

//check for terraintypes and add those
Expand Down

0 comments on commit e577d04

Please sign in to comment.