update search path

This commit is contained in:
chuanweizhang2013 2014-03-19 17:23:06 +08:00
parent a0b8200b79
commit 46d58775d7
2 changed files with 15 additions and 11 deletions

View File

@ -560,13 +560,16 @@ private:
void startRuntime() void startRuntime()
{ {
vector<string> oldSearchPathArray; vector<string> searchPathArray;
oldSearchPathArray=FileUtils::getInstance()->getSearchPaths(); searchPathArray=FileUtils::getInstance()->getSearchPaths();
vector<string> newSearchPathArray;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
if (g_resourcePath.empty()) if (g_resourcePath.empty())
{ {
g_resourcePath = FileUtils::getInstance()->getWritablePath(); extern std::string getCurAppPath();
string resourcePath = getCurAppPath();
resourcePath.append("/../../");
resourcePath =replaceAll(resourcePath,"\\","/");
g_resourcePath = resourcePath;
} }
#else #else
@ -575,12 +578,8 @@ void startRuntime()
#endif #endif
g_resourcePath=replaceAll(g_resourcePath,"\\","/"); g_resourcePath=replaceAll(g_resourcePath,"\\","/");
newSearchPathArray.push_back(g_resourcePath); searchPathArray.insert(searchPathArray.begin(),g_resourcePath);
FileUtils::getInstance()->setSearchPaths(newSearchPathArray); FileUtils::getInstance()->setSearchPaths(searchPathArray);
for (unsigned i = 0; i < oldSearchPathArray.size(); i++)
{
FileUtils::getInstance()->addSearchPath(oldSearchPathArray[i]);
}
static ConsoleCustomCommand s_customCommand; static ConsoleCustomCommand s_customCommand;
auto engine = LuaEngine::getInstance(); auto engine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine); ScriptEngineManager::getInstance()->setScriptEngine(engine);

View File

@ -52,6 +52,11 @@ using namespace cocos2d;
@synthesize menu; @synthesize menu;
std::string getCurAppPath(void)
{
return [[[NSBundle mainBundle] bundlePath] UTF8String];
}
-(void) dealloc -(void) dealloc
{ {
Director::getInstance()->end(); Director::getInstance()->end();