private void writeTile(Tile tile, XMLWriter w) throws IOException {
        w.startElement("tile");
        w.writeAttribute("id", tile.getId());

        writeProperties(tile.getProperties(), w);

        if (tile instanceof AnimatedTile)
            writeAnimation(((AnimatedTile)tile).getSprite(), w);

        w.endElement();
    }