23 load(filename, configFile);
31 tinyxml2::XMLElement *tilesetElement = doc.
FirstChildElement(
"tileset").ToElement();
33 throw EXCEPTION(
"Invalid tileset:", configFile);
35 std::string name = tilesetElement->Attribute(
"name");
37 m_tileWidth = tilesetElement->UnsignedAttribute(
"tilewidth");
38 m_tileHeight = tilesetElement->UnsignedAttribute(
"tileheight");
40 u16 tileCount = tilesetElement->UnsignedAttribute(
"tilecount");
43 tinyxml2::XMLElement *tileElement = tilesetElement->FirstChildElement(
"tile");
45 u16 tileID = tileElement->UnsignedAttribute(
"id");
46 u16 tileType = tileElement->UnsignedAttribute(
"type");
50 tinyxml2::XMLElement *animationElement = tileElement->FirstChildElement(
"animation");
51 if (animationElement) {
52 tinyxml2::XMLElement *frameElement = animationElement->FirstChildElement(
"frame");
53 while (frameElement) {
54 u16 frameTileID = frameElement->UnsignedAttribute(
"tileid");
55 u16 frameDuration = frameElement->UnsignedAttribute(
"duration");
59 frameElement = frameElement->NextSiblingElement(
"frame");
63 m_info.push_back(tileType);
66 tileElement = tileElement->NextSiblingElement(
"tile");
tinyxml2::XMLHandle FirstChildElement(const char *element)
void setTile(u16 id, Tile &tile)
void loadFromFile(const std::string &filename)
Load the texture from a file on the disk.
#define EXCEPTION(args...)
void addAnimationFrame(u16 tileID, u16 duration)
std::vector< u16 > m_info
const std::string & filename() const
Return the filename of the texture.
void load(const std::string &filename, const std::string &configFile)
std::vector< Tile > m_tiles