}
}
}
private Tile unmarshalTile(TileSet set, Node t, String baseDir) throws Exception {
Tile tile = null;
NodeList children = t.getChildNodes();
boolean isAnimated = false;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if ("animation".equalsIgnoreCase(child.getNodeName())) {
isAnimated = true;
break;
}
}
try {
if (isAnimated) {
tile = (Tile) unmarshalClass(AnimatedTile.class, t);
} else {
tile = (Tile) unmarshalClass(Tile.class, t);
}
} catch (Exception e) {
Log.ger.error("failed creating tile: " + e.getLocalizedMessage());
// e.printStackTrace();
return tile;
}
tile.setTileSet(set);
readProperties(children, tile.getProperties());
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if ("image".equalsIgnoreCase(child.getNodeName())) {
int id = getAttribute(child, "id", -1);
Image img = unmarshalImage(child, baseDir);
if (id < 0) {
id = set.addImage(img);
}
tile.setImage(id);
} else if ("animation".equalsIgnoreCase(child.getNodeName())) {
// TODO: fill this in once XMLMapWriter is complete
}
}