本文整理汇总了C++中Tileset::HasError方法的典型用法代码示例。如果您正苦于以下问题:C++ Tileset::HasError方法的具体用法?C++ Tileset::HasError怎么用?C++ Tileset::HasError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tileset
的用法示例。
在下文中一共展示了Tileset::HasError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseText
void Map::ParseText(const string &text)
{
// Create a tiny xml document and use it to parse the text.
TiXmlDocument doc;
doc.Parse(text.c_str());
// Check for parsing errors.
if (doc.Error())
{
has_error = true;
error_code = TMX_PARSING_ERROR;
error_text = doc.ErrorDesc();
return;
}
TiXmlNode *mapNode = doc.FirstChild("map");
TiXmlElement* mapElem = mapNode->ToElement();
// Read the map attributes.
mapElem->Attribute("version", &version);
mapElem->Attribute("width", &width);
mapElem->Attribute("height", &height);
mapElem->Attribute("tilewidth", &tile_width);
mapElem->Attribute("tileheight", &tile_height);
// Read the orientation
std::string orientationStr = mapElem->Attribute("orientation");
if (!orientationStr.compare("orthogonal"))
{
orientation = TMX_MO_ORTHOGONAL;
}
else if (!orientationStr.compare("isometric"))
{
orientation = TMX_MO_ISOMETRIC;
}
// Read the map properties.
const TiXmlNode *propertiesNode = mapElem->FirstChild("properties");
if (propertiesNode)
{
properties.Parse(propertiesNode);
}
// Iterate through all of the tileset elements.
const TiXmlNode *tilesetNode = mapNode->FirstChild("tileset");
while (tilesetNode)
{
// Allocate a new tileset and parse it.
Tileset *tileset = new Tileset();
tileset->Parse(tilesetNode->ToElement(), file_path);
if (tileset->HasError())
{
has_error = true;
error_code = 1;
error_text = tileset->GetErrorText();
return;
}
// Add the tileset to the list.
tilesets.push_back(tileset);
tilesetNode = mapNode->IterateChildren("tileset", tilesetNode);
}
// Iterate through all of the layer elements.
TiXmlNode *layerNode = mapNode->FirstChild("layer");
while (layerNode)
{
// Allocate a new layer and parse it.
Layer *layer = new Layer(this);
layer->Parse(layerNode);
// Add the layer to the list.
layers.push_back(layer);
layerNode = mapNode->IterateChildren("layer", layerNode);
}
// Iterate through all of the objectgroup elements.
TiXmlNode *objectGroupNode = mapNode->FirstChild("objectgroup");
while (objectGroupNode)
{
// Allocate a new object group and parse it.
ObjectGroup *objectGroup = new ObjectGroup();
objectGroup->Parse(objectGroupNode);
// Add the object group to the list.
object_groups.push_back(objectGroup);
objectGroupNode = mapNode->IterateChildren("objectgroup", objectGroupNode);
}
}