void ShareGM::parseData() { if (m_dataMap.size()>0) { return; } CSVFile* file = (CSVFile*)FileUtils::sharedFileUtils()->loadCSVFile(CSV_ROOT("shareFb.csv")); if(!file) { return; } int row = file->getRowNum(); for(int i = 1; i < row; ++i) { int id = atoi(file->get(i,0)); ShareMap::iterator iter = m_dataMap.find(id); if(iter != m_dataMap.end()) { delete iter->second; m_dataMap.erase(iter); } ShareData* cfg = new ShareData(); cfg->id = id; cfg->desc = file->get(i,1); cfg->url = file->get(i,2); m_dataMap[id] = cfg; } FileUtils::sharedFileUtils()->releaseFile(CSV_ROOT("shareFb.csv")); }
void LoadScene::loadResource(float fdetal) { CSVFile* tFile = (CSVFile*)FileUtils::sharedFileUtils()->getFile(CSV_ROOT("preloadRes.csv")); switch( atoi(tFile->get(mCurrIndex+1,0)) ) { case LOAD_RES_MODEL: { //先判断是角色还是特效然后判断是否需要加载plist文件进缓存 string str = tFile->get(mCurrIndex+1,1); int pos = str.find("plist"); if (pos != string::npos) { string pngStr = str.substr(0,pos); pngStr = pngStr.append("png"); CCTextureCache::sharedTextureCache()->addImageAsync(pngStr.c_str(),this,callfuncO_selector(LoadScene::loadAsyncImg)); LoadResourceInfo tRes; tRes.FilePath = tFile->get(mCurrIndex+1,1); tRes.FileName = tFile->get(mCurrIndex+1,2); tRes.Loadtype = sLoadType::eEffect; mResourceVec.push_back(tRes); } }break; case LOAD_BACKGROUND_SND: { char str[30]={0}; #if BATTLE_TEST sprintf(str,"BGM/Test/%d.mp3",atoi(tFile->get(mCurrIndex+1,1))); #else sprintf(str,"BGM/%d.ogg",atoi(tFile->get(mCurrIndex+1,1))); #endif CCLOG("Load BGM %s",tFile->get(mCurrIndex+1,1)); SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(tFile->get(mCurrIndex+1,1)); }break; case LOAD_EFFECT_SND: { char str[30]={0}; #if BATTLE_TEST sprintf(str,"SFX/Test/%d.mp3",atoi(tFile->get(mCurrIndex+1,1))); #else sprintf(str,"SFX/%d.ogg",atoi(tFile->get(mCurrIndex+1,1))); #endif CCLOG("Load SFX %s",tFile->get(mCurrIndex+1,1)); SimpleAudioEngine::sharedEngine()->preloadEffect(tFile->get(mCurrIndex+1,1)); }break; } ++mCurrIndex; float tPercent = mCurrIndex*100.0f/(tFile->getRowNum() + 20); //20是跑空帧 mProgress->setValue(tPercent); //进度条 m_pZombieSprite->setPositionX(mProgress->getPositionX()+mProgress->getContentSize().width*(tPercent>100?100.0f:tPercent)/100-5); //僵尸位置 if (tPercent >= 100) loadResouceEnd(); }