diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp index 0f954e2218..e4d09e66b5 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp @@ -560,27 +560,26 @@ private: void startRuntime() { - vector oldSearchPathArray; - oldSearchPathArray=FileUtils::getInstance()->getSearchPaths(); - vector newSearchPathArray; + vector searchPathArray; + searchPathArray=FileUtils::getInstance()->getSearchPaths(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) 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 g_resourcePath = FileUtils::getInstance()->getWritablePath(); #endif - + g_resourcePath=replaceAll(g_resourcePath,"\\","/"); - newSearchPathArray.push_back(g_resourcePath); - FileUtils::getInstance()->setSearchPaths(newSearchPathArray); - for (unsigned i = 0; i < oldSearchPathArray.size(); i++) - { - FileUtils::getInstance()->addSearchPath(oldSearchPathArray[i]); - } + searchPathArray.insert(searchPathArray.begin(),g_resourcePath); + FileUtils::getInstance()->setSearchPaths(searchPathArray); static ConsoleCustomCommand s_customCommand; auto engine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm index af5df54d00..37392458d3 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm @@ -52,6 +52,11 @@ using namespace cocos2d; @synthesize menu; +std::string getCurAppPath(void) +{ + return [[[NSBundle mainBundle] bundlePath] UTF8String]; +} + -(void) dealloc { Director::getInstance()->end();