From 5af89f5d4660c03e818128c21a5bb8def8662d90 Mon Sep 17 00:00:00 2001 From: chuanweizhang2013 Date: Mon, 1 Sep 2014 01:57:08 -0700 Subject: [PATCH 1/2] fixed error --- .../frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 eeaf81e555..19578e7463 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 @@ -42,7 +42,7 @@ using namespace cocos2d; bool g_landscape = false; bool g_windTop = false; cocos2d::Size g_screenSize; -GLView* g_eglView = nullptr; +GLViewImpl* g_eglView = nullptr; static AppController* g_nsAppDelegate=nullptr; @@ -103,7 +103,7 @@ std::string getCurAppPath(void) height = tmpvalue; } g_windTop = ConfigParser::getInstance()->isWindowTop(); - g_eglView = GLView::createWithRect([viewName cStringUsingEncoding:NSUTF8StringEncoding],cocos2d::Rect(0.0f,0.0f,width,height),frameZoomFactor); + g_eglView = GLViewImpl::createWithRect([viewName cStringUsingEncoding:NSUTF8StringEncoding],cocos2d::Rect(0.0f,0.0f,width,height),frameZoomFactor); auto director = Director::getInstance(); director->setOpenGLView(g_eglView); From 4ada914426393a572ce364dd9959b5b0d76be2ca Mon Sep 17 00:00:00 2001 From: chuanweizhang2013 Date: Mon, 1 Sep 2014 02:35:08 -0700 Subject: [PATCH 2/2] mac writable path --- .../frameworks/runtime-src/Classes/runtime/Runtime.cpp | 5 +++++ .../runtime-src/proj.ios_mac/mac/SimulatorApp.mm | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp index 9ff414a691..85c7c6c858 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp @@ -1136,6 +1136,11 @@ bool initRuntime() #endif g_resourcePath = FileUtils::getInstance()->getWritablePath(); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + std::string getCurAppName(void); + g_resourcePath += getCurAppName(); + g_resourcePath +="/"; +#endif g_resourcePath += "debugruntime/"; g_resourcePath=replaceAll(g_resourcePath,"\\","/"); 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 19578e7463..c6de5edcdc 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 @@ -58,6 +58,16 @@ std::string getCurAppPath(void) return [[[NSBundle mainBundle] bundlePath] UTF8String]; } +std::string getCurAppName(void) +{ + string appName = [[[NSProcessInfo processInfo] processName] UTF8String]; + int found = appName.find(" "); + if (found!=std::string::npos) + appName = appName.substr(0,found); + + return appName; +} + -(void) dealloc { Director::getInstance()->end();