bool GAFAsset::initWithGAFFile(const std::string& filePath, GAFTextureLoadDelegate_t delegate, GAFLoader* customLoader /*= nullptr*/) { m_gafFileName = filePath; std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(filePath); bool isLoaded = false; if (customLoader) { isLoaded = customLoader->loadFile(fullfilePath, this); } else { GAFLoader* loader = new GAFLoader(); isLoaded = loader->loadFile(fullfilePath, this); delete loader; } if (m_timelines.empty()) { return false; } if (isLoaded && m_state == State::Normal) { m_textureManager = new GAFAssetTextureManager(); GAFShaderManager::Initialize(); loadTextures(fullfilePath, delegate); } return isLoaded; }
bool GAFAsset::initWithGAFBundle(const std::string& zipFilePath, const std::string& entryFile, GAFTextureLoadDelegate_t delegate, GAFLoader* customLoader /*= nullptr*/) { m_gafFileName = zipFilePath; m_gafFileName.append("/" + entryFile); std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(zipFilePath); cocos2d::ZipFile bundle(fullfilePath); ssize_t sz = 0; unsigned char* gafData = bundle.getFileData(entryFile, &sz); bool isLoaded = false; if (gafData && sz) { if (customLoader) { customLoader->loadData(gafData, sz, this); } else { GAFLoader* loader = new GAFLoader(); isLoaded = loader->loadData(gafData, sz, this); delete loader; } } if (isLoaded && m_state == State::Normal) { m_textureManager = new GAFAssetTextureManager(); GAFShaderManager::Initialize(); loadTextures(entryFile, delegate, &bundle); } return isLoaded; }
bool GAFAsset::initWithGAFBundle(const std::string& zipFilePath, const std::string& entryFile, GAFTextureLoadDelegate_t delegate /*= NULL*/) { GAFLoader* loader = new GAFLoader(); m_gafFileName = zipFilePath; m_gafFileName.append("/" + entryFile); std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(zipFilePath); cocos2d::ZipFile bundle(fullfilePath); ssize_t sz = 0; unsigned char* gafData = bundle.getFileData(entryFile, &sz); bool isLoaded = false; if (gafData && sz) { isLoaded = loader->loadData(gafData, sz, this); } if (isLoaded) { loadTextures(entryFile, delegate, &bundle); } delete loader; return isLoaded; }
bool GAFAsset::initWithGAFFile(const std::string& filePath, GAFTextureLoadDelegate_t delegate) { GAFLoader* loader = new GAFLoader(); m_gafFileName = filePath; std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(filePath); bool isLoaded = loader->loadFile(fullfilePath, this); if (m_timelines.empty()) { delete loader; return false; } if (isLoaded) { loadTextures(fullfilePath, delegate); } delete loader; return isLoaded; }