bool CCSpriterX::initWithFile(const char *filename) { mCurrEntity = 0; unsigned long filesize; const char *path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(filename); char *buffer = (char *)CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &filesize); if (buffer == NULL) return false; TiXmlDocument doc; doc.Parse(buffer); TiXmlNode *root = doc.FirstChild("spriter_data"); if (root) { TiXmlElement *element = root->ToElement(); const char *version = element->Attribute("scml_version"); const char *generator = element->Attribute("generator"); const char *generatorVersion = element->Attribute("generator_version"); for (TiXmlNode* entityNode = root->FirstChild(); entityNode; entityNode = entityNode->NextSibling()) { element = entityNode->ToElement(); if (element) { const char *tab = element->Value(); if (strcmp(tab, "folder")==0) { Folder *folder = new Folder(); folder->Init(entityNode); mFolders.push_back(folder); } else if (strcmp(tab, "entity")==0) { int intValue; Entity *entity = new Entity(); if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS) entity->SetId(intValue); entity->SetName(element->Attribute("name")); for (TiXmlNode* animationNode = entityNode->FirstChild(); animationNode; animationNode = animationNode->NextSibling()) { Animation *animation = new Animation(); animation->Init(animationNode, this); entity->AddAnimation(animation); } mEntities.push_back(entity); } } } } CC_SAFE_DELETE_ARRAY(buffer); this->scheduleUpdate(); return true; }