本文整理汇总了C++中XMLElement::FirstChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::FirstChild方法的具体用法?C++ XMLElement::FirstChild怎么用?C++ XMLElement::FirstChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::FirstChild方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_conditional
ConditionalNode* AST::do_conditional(tinyxml2::XMLElement* conditional) { /* {{{ */
using namespace tinyxml2;
ConditionalNode* ret = new ConditionalNode();
XMLElement* cond = conditional->FirstChildElement("cond");
if (cond == NULL || std::string(cond->Value()) != "cond") {
std::cerr << "Condition has to come first in a conditional" << std::endl;
exit(1);
}
// Add condition
// Condition is an operation (e.g. +, -, <)
if (cond->FirstChildElement("o") != NULL) {
ret->set_condition(do_operator(cond->FirstChildElement("o")));
}
// Condition is a variable
else if (cond->FirstChildElement("v") != NULL) {
// Set it to variable
std::string var_name = cond->FirstChild()->Value();
ret->set_condition(new ValueNode(var_name, reg_number(var_name, VAR_REG)));
}
// Condition is a constant
else if (cond->FirstChildElement("c") != NULL) {
// Set it to variable (has to be int)
std::string val(cond->FirstChild()->Value());
int i;
// Parse int
sscanf(val.c_str(), "%d", &i);
ret->set_condition(new ValueNode(i));
}
else {
std::cerr << "Invalid condition in conditional" << std::endl;
exit(1);
}
// Add first body (true)
cond = cond->NextSiblingElement("body");
ret->set_body_true(process_node(cond->FirstChildElement()));
// Add second body (false)
cond = cond->NextSiblingElement("body");
ret->set_body_false(process_node(cond->FirstChildElement()));
return ret;
} /* }}} */
示例2: do_assignment
AssignmentNode* AST::do_assignment(tinyxml2::XMLElement* setq) { /* {{{ */
using namespace tinyxml2;
AssignmentNode* ret = new AssignmentNode();
// Has to be assigned to a variable
XMLElement* operand = setq->FirstChildElement("v");
if (left == NULL) {
std::cerr << "Not an assignment to variable" << std::endl;
exit(1);
}
// Set left operand
// Get variable name
std::string var_name(operand->FirstChild()->Value());
ret->set_left(new ValueNode(var_name, reg_number(var_name, VAR_REG)));
// Set right operand
// Focus on right operand
operand = operand->NextSiblingElement();
// See what kind of operand it is (another operation, const, var?)
std::string operand_type(operand->Value());
// Right operand is an operation (e.g. +, -, <)
if (operand_type == "o") {
ret->set_right(do_operator(operand));
}
// Right operand is a variable
else if (operand_type == "v") {
// Set it to variable
std::string var_name = operand->FirstChild()->Value();
ret->set_right(new ValueNode(var_name, reg_number(var_name, VAR_REG)));
}
// Right oprand is a constant
else if (operand_type == "c") {
// Set it to variable (has to be int)
std::string val(operand->FirstChild()->Value());
int i;
// Parse int
sscanf(val.c_str(), "%d", &i);
ret->set_right(new ValueNode(i));
}
return ret;
} /* }}} */
示例3:
int
CSettings::ParseOutputs(XMLElement *Outputs)
{
// Parse Outputs
XMLElement *Output = Outputs->FirstChildElement("output");
int NumberOfOutputs = 0;
while(Output)
{
OutputContainer OutputParse;
NumberOfOutputs++;
if(!Output->Attribute("name"))
{
Log.error("Output entry has no name\n");
return false;
}
// Check if there is a duplicate name
OutputParse.name = Output->Attribute("name");
for(list<OutputContainer>::iterator i=OutputsDB.begin(); i != OutputsDB.end(); ++i)
{
if(OutputParse.name.compare((*i).name) == 0)
{
Log.error("Duplicate output name [%s]\n", OutputParse.name.c_str());
return false;
}
}
OutputParse.type = Output->Attribute("type");
XMLNode *OutSettings = Output->FirstChild();
while(OutSettings)
{
if(OutSettings->Value() && OutSettings->ToElement()->GetText())
{
OutputParse.settings[OutSettings->Value()] = OutSettings->ToElement()->GetText();
Log.debug("parsed [%s]=[%s]", OutSettings->Value(), OutputParse.settings[OutSettings->Value()].c_str());
}
OutSettings = OutSettings->NextSibling();
}
OutputsDB.push_back(OutputParse);
Output = Output->NextSiblingElement("output");
}
Log.log("Parsed %d outputs\n", NumberOfOutputs);
return true;
}
示例4:
XMLElement& COption<float>::operator << (XMLElement& root)
{
XMLElement* optionNode = root.FirstChildElement(m_name);
if (optionNode == NULL)
{
UseDefault:
UseDefault();
return root;
}
XMLNode* content = optionNode->FirstChild();
if (content == NULL)
goto UseDefault;
LPCSTR value = content->ToText()->Value();
m_value = (float)atof(value);
if (!IsValid(m_value))
UseDefault();
return root;
}
示例5: GetNodeText_len
int CTinyXMLParser::GetNodeText_len(LPCTSTR strNodeName,TCHAR *pDestBuffer,int nNode/*=0*/)
{
try
{
XMLElement * Rootelement = m_pXMLDom->RootElement();
if(Rootelement==NULL)return 0;
XMLElement * pFindElement = Rootelement->FirstChildElement(strNodeName);
if(pFindElement==NULL)return 0;
const char * pValue = pFindElement->FirstChild()->Value();
int nLen = strlen(pValue);
if(pDestBuffer==NULL){
pDestBuffer = new char[nLen+1];
}
strcpy(pDestBuffer,pValue);
pDestBuffer[nLen+1]='\0';
return nLen;
/*
HRESULT hr;
MSXML2::IXMLDOMNodeListPtr List = m_pXMLDom->getElementsByTagName((_bstr_t)strNodeName);
long lNodesCount = 0;
hr = List->get_length(&lNodesCount);
if(SUCCEEDED(hr) && (nNode<lNodesCount ))
{
MSXML2::IXMLDOMNodePtr Node = List->item[nNode];
int nLen = _tcslen(Node->text);
if(pDestBuffer==NULL)
{
pDestBuffer = new TCHAR[nLen+1];
}
_tcscpy(pDestBuffer,Node->text);
pDestBuffer[nLen+1]='\0';
return nLen;
}
*/
return 0;
}
catch (...)
{
}
return 0;
}
示例6: example_3
int example_3()
{
static const char* xml =
"<?xml version=\"1.0\"?>"
"<!DOCTYPE PLAY SYSTEM \"play.dtd\">"
"<PLAY>"
"<TITLE>A Midsummer Night's Dream</TITLE>"
"</PLAY>";
XMLDocument doc;
doc.Parse( xml );
XMLElement* titleElement = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" );
const char* title = titleElement->GetText();
printf( "Name of play (1): %s\n", title );
XMLText* textNode = titleElement->FirstChild()->ToText();
title = textNode->Value();
printf( "Name of play (2): %s\n", title );
return doc.ErrorID();
}
示例7: readXML
void XMLConfig::readXML(const char* path){
XMLDocument doc;
cout << "Reading file at: " << path << endl;
doc.LoadFile(path);
// arquivosDeEntrada
XMLElement* arquivosDeEntrada = doc.FirstChildElement("aplicacao")->FirstChildElement("arquivosDeEntrada");
XMLNode* arquivo = arquivosDeEntrada->FirstChild();
while(arquivo != NULL){
XMLElement* arq = arquivo->ToElement();
if(strcmp(arq->Name(),"arquivoDaArena") == 0){
this->arena = File(arq->Attribute("nome"),
arq->Attribute("caminho"),
arq->Attribute("tipo"));
}
arquivo = arquivo->NextSibling();
}
cout << "OK!"<<endl;
}
示例8: LoadGeometry
//.........这里部分代码省略.........
return false;
temp = temp.substr(1);
if(temp != verticesid) // verify source is the same as vertices id loaded above in current mesh
return false;
if(!XMLHelper::GetElementAttribute(verticesInput,"offset",temp)) // get vertices offset in <p> element
return false;
if(!StringHelper::from_string(vertices_offset,temp))
return false;
std::string normalid;
int normal_offset;
bool hasNormals;
// get normals <input>
XMLElement* normalInput = XMLHelper::GetChildElement(triangles,"input","semantic","NORMAL");
if(!XMLHelper::GetElementAttribute(normalInput,"source",normalid))
hasNormals = false;
else {
normalid = normalid.substr(1);
hasNormals = true;
}
if(hasNormals && !XMLHelper::GetElementAttribute(normalInput,"offset",temp)) // get offset for normals in <p> element
return false;
else {
if(!StringHelper::from_string<int>(normal_offset,temp))
return false;
}
XMLElement *pelement = XMLHelper::GetChildElement(triangles,"p");
if(pelement == NULL)
return false;
XMLText *innerText = pelement->FirstChild()->ToText();
if(innerText == NULL)
return false;
std::string tarray(innerText->Value());
std::vector<int> IndexArray = StringHelper::ConvertStringToTArray<int>(tarray);
int indexcount = IndexArray.size();
if((indexcount % (3*tricount)) != 0)
return false;
int indexstride = indexcount/(3*tricount);
TriangleGroup trigroup;
trigroup.setMaterialSymbol(materialsymbol);
// TODO: add check for positionid & normalid
if(hasNormals) {
Source& vertices = sources[normalid];
ucount = vertices.getUnitCount();
if(ucount < 3)
return false;
int vcount = vertices.getArrayValues().size() / ucount;
for(int i=0;i<vcount;i++) {
int idx = ucount*i;
vec3 v(vertices.getArrayValues()[idx],vertices.getArrayValues()[idx+1],vertices.getArrayValues()[idx+2]);
trigroup.getNormals().push_back(v);
}
}
for(int i=0;i<tricount*3;i++) {
int vpos = i*indexstride + vertices_offset;
trigroup.getTriangleIndices().push_back(IndexArray[vpos]);
if(hasNormals) {
示例9: LoadMaterial
bool COLLADAImporter::LoadMaterial(XMLElement* colladaRootNode,const std::string& id)
{
if(m_Materials.find(id) != m_Materials.end()) // material already loaded
return true;
XMLElement *materials = XMLHelper::GetChildElement(colladaRootNode,"library_materials");
if(materials == NULL)
return false;
XMLElement *material = XMLHelper::GetChildElement(materials,"material","id",id);
if(material == NULL)
return false;
XMLElement *effect = XMLHelper::GetChildElement(material,"instance_effect");
if(effect == NULL)
return false;
std::string effectid;
if(!XMLHelper::GetElementAttribute(effect,"url",effectid))
return false;
effectid = effectid.substr(1); // remove leading "#"
XMLElement *effects = XMLHelper::GetChildElement(colladaRootNode,"library_effects");
if(effects == NULL)
return false;
effect = XMLHelper::GetChildElement(effects,"id",effectid);
if(effect == NULL)
return false;
XMLElement *profile = XMLHelper::GetChildElement(effect,"profile_COMMON");
if(profile == NULL)
return false;
XMLElement *technique = XMLHelper::GetChildElement(profile,"technique");
if(technique == NULL)
return false;
XMLElement *bp = XMLHelper::GetChildElement(technique,"blinn");
if(bp == NULL) {
bp = XMLHelper::GetChildElement(technique,"phong");
if(bp == NULL) {
bp = XMLHelper::GetChildElement(technique,"lambert");
if(bp == NULL)
return false;
}
}
Material mat;
// ambient
XMLElement *ambient = XMLHelper::GetChildElement(bp,"ambient");
if(ambient != NULL) {
XMLElement *color = XMLHelper::GetChildElement(ambient,"color");
if(color != NULL) {
XMLText *value = color->FirstChild()->ToText();
if(value != NULL) {
std::vector<float> c = StringHelper::ConvertStringToTArray<float>(value->Value());
if(c.size() >= 3 )
mat.m_Ambient = vec3(c[0],c[1],c[2]);
}
}
}
//diffuse
XMLElement *diffuse = XMLHelper::GetChildElement(bp,"diffuse");
if(diffuse != NULL) {
XMLElement* color = XMLHelper::GetChildElement(diffuse,"color");
if(color != NULL) {
XMLText* value = color->FirstChild()->ToText();
if(value != NULL) {
std::vector<float> c = StringHelper::ConvertStringToTArray<float>(value->Value());
if(c.size() >= 3 )
mat.m_Diffuse = vec3(c[0],c[1],c[2]);
}
}
}
//specular
XMLElement *specular = XMLHelper::GetChildElement(bp,"specular");
if(specular != NULL) {
XMLElement* color = XMLHelper::GetChildElement(specular,"color");
if(color != NULL) {
XMLText* value = color->FirstChild()->ToText();
if(value != NULL) {
std::vector<float> c = StringHelper::ConvertStringToTArray<float>(value->Value());
if(c.size() >= 3 )
mat.m_Specular = vec3(c[0],c[1],c[2]);
}
}
}
//emission
XMLElement *emission = XMLHelper::GetChildElement(bp,"emission");
if(emission != NULL) {
XMLElement* color = XMLHelper::GetChildElement(emission,"color");
if(color != NULL) {
XMLText* value = color->FirstChild()->ToText();
if(value != NULL) {
std::vector<float> c = StringHelper::ConvertStringToTArray<float>(value->Value());
if(c.size() >= 3 )
mat.m_Emmission = vec3(c[0],c[1],c[2]);
}
}
}
m_Materials[id] = mat;
//.........这里部分代码省略.........
示例10: open
bool FractalConfiguration::open(string filename)
{
if(invalidID())
return true;
m_dirty = false;
XMLDocument doc;
// Parse file
doc.LoadFile(filename.c_str());
if(doc.Error())
{
m_last_error = doc.GetErrorStr1();
return true;
}
// Get data
XMLElement *root = doc.RootElement();
string name = string(root->Name());
if(name != "fractal")
{
m_last_error = "Configuration file is invalid!";
return true;
}
if(root->Attribute("id", m_id.c_str()))
{
XMLNode *node = root->FirstChild();
// Loop over all properties
while(node != NULL)
{
XMLElement *element = node->ToElement();
if(element == NULL)
{
m_last_error = "Configuration file is invalid!";
return true;
}
// Get name and type (attributes)
const char* tmp_name = element->Attribute("name");
const char* tmp_type = element->Attribute("type");
if(tmp_name == NULL || tmp_type == NULL)
{
m_last_error = "Configuration file is invalid!";
return true;
}
string name(tmp_name);
string type(tmp_type);
// Get text
const char* tmp_text = element->GetText();
string text = "";
if(tmp_text != NULL)
text = tmp_text;
// Set property
if(type == "string")
{
if(setStringProperty(name, text))
return true;
}
else if(type == "int")
{
int value;
if(stringToInt(text, &value))
{
m_last_error = "Error in configuration: " + text + " should be an integer";
return true;
}
if(setIntProperty(name, value))
return true;
}
else if(type == "double")
{
double value;
if(stringToDouble(text, &value))
{
m_last_error = "Error in configuration: " + text + " should be a double";
return true;
}
if(setDoubleProperty(name, value))
return true;
}
else if(type == "bool")
{
bool value;
if(text == "1")
value = true;
else if(text == "0")
//.........这里部分代码省略.........
示例11: ReadFile
bool XmlHandler::ReadFile(const char* fileName, OVR::Render::RenderDevice* pRender,
OVR::Render::Scene* pScene,
OVR::Array<Ptr<CollisionModel> >* pCollisions,
OVR::Array<Ptr<CollisionModel> >* pGroundCollisions,
bool srgbAware /*= false*/,
bool anisotropic /*= false*/)
{
if(pXmlDocument->LoadFile(fileName) != 0)
{
return false;
}
// Extract the relative path to our working directory for loading textures
filePath[0] = 0;
intptr_t pos = 0;
intptr_t len = strlen(fileName);
for(intptr_t i = len; i > 0; i--)
{
if (fileName[i-1]=='\\' || fileName[i-1]=='/')
{
memcpy(filePath, fileName, i);
filePath[i] = 0;
break;
}
}
// Load the textures
OVR_DEBUG_LOG_TEXT(("Loading textures..."));
XMLElement* pXmlTexture = pXmlDocument->FirstChildElement("scene")->FirstChildElement("textures");
OVR_ASSERT(pXmlTexture);
if (pXmlTexture)
{
pXmlTexture->QueryIntAttribute("count", &textureCount);
pXmlTexture = pXmlTexture->FirstChildElement("texture");
}
for(int i = 0; i < textureCount; ++i)
{
const char* textureName = pXmlTexture->Attribute("fileName");
intptr_t dotpos = strcspn(textureName, ".");
char fname[300];
if (pos == len)
{
OVR_sprintf(fname, 300, "%s", textureName);
}
else
{
OVR_sprintf(fname, 300, "%s%s", filePath, textureName);
}
int textureLoadFlags = 0;
textureLoadFlags |= srgbAware ? TextureLoad_SrgbAware : 0;
textureLoadFlags |= anisotropic ? TextureLoad_Anisotropic : 0;
SysFile* pFile = new SysFile(fname);
Ptr<Texture> texture;
if (textureName[dotpos + 1] == 'd' || textureName[dotpos + 1] == 'D')
{
// DDS file
Texture* tmp_ptr = LoadTextureDDSTopDown(pRender, pFile, textureLoadFlags);
if(tmp_ptr)
{
texture.SetPtr(*tmp_ptr);
}
}
else
{
Texture* tmp_ptr = LoadTextureTgaTopDown(pRender, pFile, textureLoadFlags, 255);
if(tmp_ptr)
{
texture.SetPtr(*tmp_ptr);
}
}
Textures.PushBack(texture);
pFile->Close();
pFile->Release();
pXmlTexture = pXmlTexture->NextSiblingElement("texture");
}
OVR_DEBUG_LOG_TEXT(("Done.\n"));
// Load the models
pXmlDocument->FirstChildElement("scene")->FirstChildElement("models")->
QueryIntAttribute("count", &modelCount);
OVR_DEBUG_LOG(("Loading models... %i models to load...", modelCount));
XMLElement* pXmlModel = pXmlDocument->FirstChildElement("scene")->
FirstChildElement("models")->FirstChildElement("model");
for(int i = 0; i < modelCount; ++i)
{
if (i % 15 == 0)
{
OVR_DEBUG_LOG_TEXT(("%i models remaining...", modelCount - i));
}
const char* name = pXmlModel->Attribute("name");
Models.PushBack(*new Model(Prim_Triangles, name));
bool isCollisionModel = false;
pXmlModel->QueryBoolAttribute("isCollisionModel", &isCollisionModel);
Models[i]->IsCollisionModel = isCollisionModel;
//.........这里部分代码省略.........
示例12: ObtainCommands
void ObtainCommands(XMLElement* registry, unsigned int* &functionCount, Function** &functions)
{
XMLElement* commands = registry->FirstChildElement("commands");
if(commands)
{
// reserve memory
unsigned int commandAmount = 0;
XMLElement* cmd = commands->FirstChildElement("command");
while(cmd)
{
++commandAmount;
// if (cmd->FirstChildElement("vecequiv"))
// ++commandAmount;
//if (cmd->FirstChildElement("alias"))
// ++commandAmount;
cmd = cmd->NextSiblingElement();
}
// fill data
*functionCount = commandAmount;
*functions = new Function[commandAmount];
cmd = commands->FirstChildElement("command");
for(unsigned int i = 0; i < commandAmount; ++i)
{
(*functions)[i].Name = 0;
(*functions)[i].Result = 0;
XMLElement* proto = cmd->FirstChildElement("proto");
if(proto)
{
XMLElement* name = proto->FirstChildElement("name");
if(name)
{
int len = strlen(name->FirstChild()->Value());
(*functions)[i].Name = new char[len + 1];
strcpy((*functions)[i].Name, name->FirstChild()->Value());
}
XMLElement* resultType = proto->FirstChildElement("ptype");
if(resultType)
{
int len = strlen(resultType->FirstChild()->Value());
(*functions)[i].Result = new char[len + 1];
strcpy((*functions)[i].Result, resultType->FirstChild()->Value());
}
else
{
int len = strlen("void");
(*functions)[i].Result = new char[len +1];
strcpy((*functions)[i].Result, "void");
}
}
unsigned int parameterAmount = 0;
XMLElement* param = cmd->FirstChildElement("param");
while(param && strcmp(param->Value(), "param") == 0)
{
++parameterAmount;
param = param->NextSiblingElement();
}
(*functions)[i].ParameterCount = parameterAmount;
(*functions)[i].Parameters = 0;
if(parameterAmount)
{
(*functions)[i].Parameters = new Parameter[parameterAmount];
param = cmd->FirstChildElement("param");
for(unsigned int j = 0; j < parameterAmount; ++j)
{
(*functions)[i].Parameters[j].Name = 0;
XMLElement* name = param->FirstChildElement("name");
if(name)
{
int len = strlen(name->FirstChild()->Value());
if(strcmp(name->FirstChild()->Value(), "residences") == 0)
len = len;
(*functions)[i].Parameters[j].Name = new char[len + 1];
strcpy((*functions)[i].Parameters[j].Name, name->FirstChild()->Value());
}
(*functions)[i].Parameters[j].Type = 0;
(*functions)[i].Parameters[j].PostType = 0;
(*functions)[i].Parameters[j].ByteSize = 0;
(*functions)[i].Parameters[j].IsConst = false;
(*functions)[i].Parameters[j].IsPointer = false;
XMLElement* type = param->FirstChildElement("ptype");
if(type)
{
int len = strlen(type->FirstChild()->Value());
(*functions)[i].Parameters[j].Type = new char[len + 1];
strcpy((*functions)[i].Parameters[j].Type, type->FirstChild()->Value());
if(type->PreviousSibling() && strstr(type->PreviousSibling()->Value(), "const") != 0)
(*functions)[i].Parameters[j].IsConst = true;
if(type->NextSibling() && strcmp(type->NextSibling()->Value(), "name") != 0)
{
int len = strlen(type->NextSibling()->Value());
(*functions)[i].Parameters[j].PostType = new char[len + 1];
strcpy((*functions)[i].Parameters[j].PostType, type->NextSibling()->Value());
//.........这里部分代码省略.........
示例13: parseTileLayer
void LevelParser::parseTileLayer(XMLElement* pTileElement, Level *pLevel)
{
// New TileLayer instance
TileLayer* pTileLayer = new TileLayer(m_tileSize, m_width, m_height, TheGame::Instance().getTilesets());
// local temporary variable
bool collidable = false;
// A multidimensional array of int values to hold our final decoded and uncompressed tile data
std::vector<std::vector<int>> data;
// xml data node
XMLElement* pDataNode = nullptr;
// to store base64 decoded information
std::string decodedIDs;
// We search for the node we need
for (XMLElement* e = pTileElement->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
{
// check if layer has properties
if (e->Value() == std::string("properties"))
{
for (XMLElement* property = e->FirstChildElement(); property != NULL; property = property->NextSiblingElement())
{
if (property->Value() == std::string("property"))
{
// Check if it is a collision layer
if (property->Attribute("name") == std::string("collidable"))
{
collidable = true;
}
}
}
}
if (e->Value() == std::string("data"))
{
pDataNode = e;
}
}
// Tile information not encoded nor compressed
if (pDataNode->Attribute("encoding") == nullptr)
{
std::vector<int> layerRow(m_width);
for (int rows = 0; rows < m_height; rows++)
{
data.push_back(layerRow);
}
XMLElement* tile = pDataNode->FirstChildElement();
int id;
for (int rows = 0; rows < m_height; rows++)
{
for (int cols = 0; cols < m_width ; cols++)
{
tile->QueryAttribute("gid", &data[rows][cols]);
tile = tile->NextSiblingElement();
}
}
}
else
{
// We get the text (our encoded/compressed data) from the data node and use the base64 decoder to decode it
for (XMLNode* e = pDataNode->FirstChild(); e != NULL; e = e->NextSibling())
{
XMLText* text = e->ToText();
std::string t = text->Value();
decodedIDs = base64_decode(t);
}
// We use the zlib library to decompress our data once again
uLongf sizeofids = m_width * m_height * sizeof(int);
std::vector<unsigned> gids(sizeofids);
uncompress((Bytef*)&gids[0], &sizeofids, (const Bytef*)decodedIDs.c_str(), decodedIDs.size());
// gids now contains all of our tile IDs, so we fill our data array with the correct values
std::vector<int> layerRow(m_width);
for (int j = 0; j < m_height; j++)
{
data.push_back(layerRow);
}
for (int rows = 0; rows < m_height; rows++)
{
for (int cols = 0; cols < m_width; cols++)
{
data[rows][cols] = gids[rows * m_width + cols];
}
}
}
pTileLayer->setTileIDs(data);
pTileLayer->setMapWidth(m_width);
// push into collision array and mark the layer as collidable if necessary
if (collidable)
{
//.........这里部分代码省略.........