}
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) {
error = "Failed creating tile: " + e.getLocalizedMessage();
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())) {
Image img = unmarshalImage(child, baseDir);
tile.setImage(img);
} else if ("animation".equalsIgnoreCase(child.getNodeName())) {
// TODO: fill this in once TMXMapWriter is complete
}
}