本文整理汇总了C++中TiXmlElement::readPos方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::readPos方法的具体用法?C++ TiXmlElement::readPos怎么用?C++ TiXmlElement::readPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::readPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadSpawns
void Map::loadSpawns(const std::string &fileName)
{
if(!m_creatures.isLoaded())
stdext::throw_exception("cannot load spawns; monsters/nps aren't loaded.");
TiXmlDocument doc;
doc.Parse(g_resources.loadFile(fileName).c_str());
if(doc.Error())
stdext::throw_exception(stdext::format("cannot load spawns xml file '%s: '%s'", fileName, doc.ErrorDesc()));
TiXmlElement* root = doc.FirstChildElement();
if(!root || root->ValueStr() != "spawns")
stdext::throw_exception("malformed spawns file");
CreatureTypePtr cType(nullptr);
for(TiXmlElement* node = root->FirstChildElement(); node; node = node->NextSiblingElement()) {
if(node->ValueTStr() != "spawn")
stdext::throw_exception("invalid spawn node");
Position centerPos = node->readPos("center");
for(TiXmlElement* cNode = node->FirstChildElement(); cNode; cNode = cNode->NextSiblingElement()) {
if(cNode->ValueStr() != "monster" && cNode->ValueStr() != "npc")
stdext::throw_exception(stdext::format("invalid spawn-subnode %s", cNode->ValueStr()));
std::string cName = cNode->Attribute("name");
stdext::tolower(cName);
stdext::trim(cName);
if (!(cType = m_creatures.getCreature(cName)))
continue;
cType->setSpawnTime(cNode->readType<int>("spawntime"));
CreaturePtr creature(new Creature);
creature->setOutfit(cType->getOutfit());
stdext::ucwords(cName);
creature->setName(cName);
centerPos.x += cNode->readType<int>("x");
centerPos.y += cNode->readType<int>("y");
centerPos.z = cNode->readType<int>("z");
addThing(creature, centerPos, 4);
}
}
}