void ResourceManager::load(const std::string& resFile) { auto file = cocos2d::FileUtils::getInstance()->fullPathForFilename(resFile); XMLReader reader; CCAssert(reader.loadDocument(file), "Couldn't load resource list file"); reader.root(); if (reader.child("Textures") && reader.child()) { do { auto id = reader.getTextAttribute("id"); CCAssert(!id.empty(), "id value is null"); auto file = reader.getTextValue(); CCAssert(!file.empty(), "file value is null"); auto texture = cocos2d::Director::getInstance()->getTextureCache()->addImage(file); CCAssert(texture, "texture is null"); m_textures.insert(std::pair<std::string, cocos2d::Texture2D*>(id, texture)); } while (reader.next()); } reader.root(); if (reader.child("Configs") && reader.child()) { do { auto id = reader.getTextAttribute("id"); CCAssert(!id.empty(), "id value is null"); auto file = reader.getTextValue(); CCAssert(!file.empty(), "file value is null"); auto ptr = XMLPtr(new XMLReader); CCAssert(ptr->loadDocument(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)), "Xml wasn't loaded properly"); m_configs.insert(std::pair<std::string, XMLPtr>(id, std::move(ptr))); } while (reader.next()); } reader.root(); if (reader.child("HUDs") && reader.child()) { do { auto id = reader.getTextAttribute("id"); CCAssert(!id.empty(), "id value is null"); auto file = reader.getTextValue(); CCAssert(!file.empty(), "file value is null"); auto layer = HUDLayer::create(file); CCAssert(layer, "layer value is null"); layer->retain(); m_hudlayers.insert(std::pair<std::string, HUDLayer*>(id, layer)); } while (reader.next()); } }