From e39195d9965092d2086a69dc803452885b1719e4 Mon Sep 17 00:00:00 2001 From: Walzer Date: Fri, 24 Jun 2011 12:43:45 +0800 Subject: [PATCH] issue #580 add RootViewController to xcode4 templates, issue #398 fix the duplicate names to cocos2d-x --- install-templates-xcode.sh | 2 +- .../Classes/AppDelegate.cpp | 23 +++-- .../Classes/AppDelegate.h | 0 .../Classes/HelloWorldScene.cpp | 0 .../Classes/HelloWorldScene.h | 0 .../Prefix.pch | 0 .../TemplateIcon.icns | Bin .../ios/AppController.h | 0 .../ios/AppController.mm | 0 .../ios/RootViewController.h | 33 ++++++ .../ios/RootViewController.mm | 5 +- .../ios/main.m | 0 .../Classes/AppDelegate.cpp | 23 +++-- .../Classes/AppDelegate.h | 0 .../Classes/HelloWorldScene.cpp | 0 .../Classes/HelloWorldScene.h | 0 .../Prefix.pch | 0 .../TemplateIcon.icns | Bin .../ios/AppController.h | 0 .../ios/AppController.mm | 0 .../ios/RootViewController.h | 0 .../ios/RootViewController.mm | 5 +- .../ios/main.m | 0 .../Classes/AppDelegate.cpp | 23 +++-- .../Classes/AppDelegate.h | 0 .../Classes/HelloWorldScene.cpp | 0 .../Classes/HelloWorldScene.h | 0 .../Prefix.pch | 0 .../TemplateIcon.icns | Bin .../ios/AppController.h | 0 .../ios/AppController.mm | 0 .../ios/RootViewController.h | 0 .../ios/RootViewController.mm | 5 +- .../ios/main.m | 0 .../Classes/AppController.h | 14 +++ .../Classes/AppController.mm | 97 ++++++++++++++++++ .../cocos2dx_lua.xctemplate/Classes/main.m | 16 +++ .../Prefix.pch | 0 .../Resources/hello.lua | 0 .../TemplateIcon.icns | Bin .../ios/main.m | 0 41 files changed, 218 insertions(+), 28 deletions(-) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/Classes/AppDelegate.cpp (73%) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/Classes/AppDelegate.h (100%) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/Classes/HelloWorldScene.cpp (100%) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/Classes/HelloWorldScene.h (100%) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/Prefix.pch (100%) mode change 100755 => 100644 rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/TemplateIcon.icns (100%) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/ios/AppController.h (100%) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/ios/AppController.mm (100%) create mode 100644 template/xcode4/cocos2dx.xctemplate/ios/RootViewController.h rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx.xctemplate}/ios/RootViewController.mm (87%) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx.xctemplate}/ios/main.m (100%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_box2d.xctemplate}/Classes/AppDelegate.cpp (73%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/Classes/AppDelegate.h (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/Classes/HelloWorldScene.cpp (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/Classes/HelloWorldScene.h (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/Prefix.pch (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/TemplateIcon.icns (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/ios/AppController.h (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/ios/AppController.mm (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/ios/RootViewController.h (100%) rename template/xcode4/{cocos2d-x.xctemplate => cocos2dx_box2d.xctemplate}/ios/RootViewController.mm (87%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_box2d.xctemplate}/ios/main.m (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_chipmunk.xctemplate}/Classes/AppDelegate.cpp (73%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/Classes/AppDelegate.h (100%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/Classes/HelloWorldScene.cpp (100%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/Classes/HelloWorldScene.h (100%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/Prefix.pch (100%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/TemplateIcon.icns (100%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/ios/AppController.h (100%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/ios/AppController.mm (100%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/ios/RootViewController.h (100%) rename template/xcode4/{cocos2d_box2d.xctemplate => cocos2dx_chipmunk.xctemplate}/ios/RootViewController.mm (87%) rename template/xcode4/{cocos2d_chipmunk.xctemplate => cocos2dx_chipmunk.xctemplate}/ios/main.m (100%) create mode 100644 template/xcode4/cocos2dx_lua.xctemplate/Classes/AppController.h create mode 100644 template/xcode4/cocos2dx_lua.xctemplate/Classes/AppController.mm create mode 100644 template/xcode4/cocos2dx_lua.xctemplate/Classes/main.m rename template/xcode4/{cocos2d_lua.xctemplate => cocos2dx_lua.xctemplate}/Prefix.pch (100%) mode change 100755 => 100644 rename template/xcode4/{cocos2d_lua.xctemplate => cocos2dx_lua.xctemplate}/Resources/hello.lua (100%) rename template/xcode4/{cocos2d_lua.xctemplate => cocos2dx_lua.xctemplate}/TemplateIcon.icns (100%) rename template/xcode4/{cocos2d_lua.xctemplate => cocos2dx_lua.xctemplate}/ios/main.m (100%) diff --git a/install-templates-xcode.sh b/install-templates-xcode.sh index a20344168a..330c56910c 100755 --- a/install-templates-xcode.sh +++ b/install-templates-xcode.sh @@ -2,7 +2,7 @@ echo 'cocos2d-x template installer' -COCOS2D_VER='cocos2d-0.99.5-x-0.8.4' +COCOS2D_VER='cocos2d-0.99.5-x-0.8.5' BASE_TEMPLATE_DIR="/Library/Application Support/Developer/Shared/Xcode" BASE_TEMPLATE_USER_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode" diff --git a/template/xcode4/cocos2d-x.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp similarity index 73% rename from template/xcode4/cocos2d-x.xctemplate/Classes/AppDelegate.cpp rename to template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp index fb9ffc4e46..e024101f3a 100644 --- a/template/xcode4/cocos2d-x.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp @@ -33,24 +33,26 @@ bool AppDelegate::initInstance() // The HelloWorld is designed as HVGA. CCEGLView * pMainWnd = new CCEGLView(); CC_BREAK_IF(! pMainWnd - || ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480)); + || ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320)); #endif // CC_PLATFORM_WIN32 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - // OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here. + // OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here. #endif // CC_PLATFORM_IOS -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - // android does not do anything -#endif +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp + // the default setting is to create a fullscreen view + // if you want to use auto-scale, please enable view->create(320,480) in main.cpp +#endif // CC_PLATFORM_ANDROID #if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE) // Initialize OpenGLView instance, that release by CCDirector when application terminate. // The HelloWorld is designed as HVGA. CCEGLView* pMainWnd = new CCEGLView(this); - CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480)); + CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480, WM_WINDOW_ROTATE_MODE_CW)); #ifndef _TRANZDA_VM_ // on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file @@ -59,6 +61,11 @@ bool AppDelegate::initInstance() #endif // CC_PLATFORM_WOPHONE +#if (CC_TARGET_PLATFORM == CC_PLATFORM_AIRPLAY) + // MaxAksenov said it's NOT a very elegant solution. I agree, haha + CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); +#endif + bRet = true; } while (0); return bRet; @@ -71,10 +78,10 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. -// pDirector->enableRetinaDisplay(true); + // pDirector->enableRetinaDisplay(true); // sets landscape mode - pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); + // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // turn on display FPS pDirector->setDisplayFPS(true); diff --git a/template/xcode4/cocos2d-x.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h similarity index 100% rename from template/xcode4/cocos2d-x.xctemplate/Classes/AppDelegate.h rename to template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h diff --git a/template/xcode4/cocos2d-x.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp similarity index 100% rename from template/xcode4/cocos2d-x.xctemplate/Classes/HelloWorldScene.cpp rename to template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp diff --git a/template/xcode4/cocos2d-x.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h similarity index 100% rename from template/xcode4/cocos2d-x.xctemplate/Classes/HelloWorldScene.h rename to template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h diff --git a/template/xcode4/cocos2d-x.xctemplate/Prefix.pch b/template/xcode4/cocos2dx.xctemplate/Prefix.pch old mode 100755 new mode 100644 similarity index 100% rename from template/xcode4/cocos2d-x.xctemplate/Prefix.pch rename to template/xcode4/cocos2dx.xctemplate/Prefix.pch diff --git a/template/xcode4/cocos2d-x.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx.xctemplate/TemplateIcon.icns similarity index 100% rename from template/xcode4/cocos2d-x.xctemplate/TemplateIcon.icns rename to template/xcode4/cocos2dx.xctemplate/TemplateIcon.icns diff --git a/template/xcode4/cocos2d-x.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx.xctemplate/ios/AppController.h similarity index 100% rename from template/xcode4/cocos2d-x.xctemplate/ios/AppController.h rename to template/xcode4/cocos2dx.xctemplate/ios/AppController.h diff --git a/template/xcode4/cocos2d-x.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx.xctemplate/ios/AppController.mm similarity index 100% rename from template/xcode4/cocos2d-x.xctemplate/ios/AppController.mm rename to template/xcode4/cocos2dx.xctemplate/ios/AppController.mm diff --git a/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.h b/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.h new file mode 100644 index 0000000000..a40c2edd28 --- /dev/null +++ b/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.h @@ -0,0 +1,33 @@ +/**************************************************************************** + Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2010 Ricardo Quesada + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#import + + +@interface RootViewController : UIViewController { + +} + +@end diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm similarity index 87% rename from template/xcode4/cocos2d_chipmunk.xctemplate/ios/RootViewController.mm rename to template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm index 3de46c4884..b7ad54b327 100644 --- a/template/xcode4/cocos2d_chipmunk.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/cocos2dx.xctemplate/ios/RootViewController.mm @@ -34,9 +34,12 @@ } */ -// Override to allow orientations other than the default portrait orientation. +// Override to allow orientations other than the default landscape orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); + + // switch to this line if you want to set portrait view + // return UIInterfaceOrientationIsPortrait( interfaceOrientation ); } - (void)didReceiveMemoryWarning { diff --git a/template/xcode4/cocos2d-x.xctemplate/ios/main.m b/template/xcode4/cocos2dx.xctemplate/ios/main.m similarity index 100% rename from template/xcode4/cocos2d-x.xctemplate/ios/main.m rename to template/xcode4/cocos2dx.xctemplate/ios/main.m diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp similarity index 73% rename from template/xcode4/cocos2d_chipmunk.xctemplate/Classes/AppDelegate.cpp rename to template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp index fb9ffc4e46..e024101f3a 100644 --- a/template/xcode4/cocos2d_chipmunk.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp @@ -33,24 +33,26 @@ bool AppDelegate::initInstance() // The HelloWorld is designed as HVGA. CCEGLView * pMainWnd = new CCEGLView(); CC_BREAK_IF(! pMainWnd - || ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480)); + || ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320)); #endif // CC_PLATFORM_WIN32 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - // OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here. + // OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here. #endif // CC_PLATFORM_IOS -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - // android does not do anything -#endif +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp + // the default setting is to create a fullscreen view + // if you want to use auto-scale, please enable view->create(320,480) in main.cpp +#endif // CC_PLATFORM_ANDROID #if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE) // Initialize OpenGLView instance, that release by CCDirector when application terminate. // The HelloWorld is designed as HVGA. CCEGLView* pMainWnd = new CCEGLView(this); - CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480)); + CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480, WM_WINDOW_ROTATE_MODE_CW)); #ifndef _TRANZDA_VM_ // on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file @@ -59,6 +61,11 @@ bool AppDelegate::initInstance() #endif // CC_PLATFORM_WOPHONE +#if (CC_TARGET_PLATFORM == CC_PLATFORM_AIRPLAY) + // MaxAksenov said it's NOT a very elegant solution. I agree, haha + CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); +#endif + bRet = true; } while (0); return bRet; @@ -71,10 +78,10 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. -// pDirector->enableRetinaDisplay(true); + // pDirector->enableRetinaDisplay(true); // sets landscape mode - pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); + // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // turn on display FPS pDirector->setDisplayFPS(true); diff --git a/template/xcode4/cocos2d_box2d.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.h similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/Classes/AppDelegate.h rename to template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.h diff --git a/template/xcode4/cocos2d_box2d.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/Classes/HelloWorldScene.cpp rename to template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp diff --git a/template/xcode4/cocos2d_box2d.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/Classes/HelloWorldScene.h rename to template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h diff --git a/template/xcode4/cocos2d_box2d.xctemplate/Prefix.pch b/template/xcode4/cocos2dx_box2d.xctemplate/Prefix.pch similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/Prefix.pch rename to template/xcode4/cocos2dx_box2d.xctemplate/Prefix.pch diff --git a/template/xcode4/cocos2d_box2d.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx_box2d.xctemplate/TemplateIcon.icns similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/TemplateIcon.icns rename to template/xcode4/cocos2dx_box2d.xctemplate/TemplateIcon.icns diff --git a/template/xcode4/cocos2d_box2d.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/ios/AppController.h rename to template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.h diff --git a/template/xcode4/cocos2d_box2d.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/ios/AppController.mm rename to template/xcode4/cocos2dx_box2d.xctemplate/ios/AppController.mm diff --git a/template/xcode4/cocos2d_box2d.xctemplate/ios/RootViewController.h b/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.h similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/ios/RootViewController.h rename to template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.h diff --git a/template/xcode4/cocos2d-x.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm similarity index 87% rename from template/xcode4/cocos2d-x.xctemplate/ios/RootViewController.mm rename to template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm index 3de46c4884..b7ad54b327 100644 --- a/template/xcode4/cocos2d-x.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/cocos2dx_box2d.xctemplate/ios/RootViewController.mm @@ -34,9 +34,12 @@ } */ -// Override to allow orientations other than the default portrait orientation. +// Override to allow orientations other than the default landscape orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); + + // switch to this line if you want to set portrait view + // return UIInterfaceOrientationIsPortrait( interfaceOrientation ); } - (void)didReceiveMemoryWarning { diff --git a/template/xcode4/cocos2d_box2d.xctemplate/ios/main.m b/template/xcode4/cocos2dx_box2d.xctemplate/ios/main.m similarity index 100% rename from template/xcode4/cocos2d_box2d.xctemplate/ios/main.m rename to template/xcode4/cocos2dx_box2d.xctemplate/ios/main.m diff --git a/template/xcode4/cocos2d_box2d.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp similarity index 73% rename from template/xcode4/cocos2d_box2d.xctemplate/Classes/AppDelegate.cpp rename to template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp index fb9ffc4e46..e024101f3a 100644 --- a/template/xcode4/cocos2d_box2d.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp @@ -33,24 +33,26 @@ bool AppDelegate::initInstance() // The HelloWorld is designed as HVGA. CCEGLView * pMainWnd = new CCEGLView(); CC_BREAK_IF(! pMainWnd - || ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480)); + || ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320)); #endif // CC_PLATFORM_WIN32 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - // OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here. + // OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here. #endif // CC_PLATFORM_IOS -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - // android does not do anything -#endif +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp + // the default setting is to create a fullscreen view + // if you want to use auto-scale, please enable view->create(320,480) in main.cpp +#endif // CC_PLATFORM_ANDROID #if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE) // Initialize OpenGLView instance, that release by CCDirector when application terminate. // The HelloWorld is designed as HVGA. CCEGLView* pMainWnd = new CCEGLView(this); - CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480)); + CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480, WM_WINDOW_ROTATE_MODE_CW)); #ifndef _TRANZDA_VM_ // on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file @@ -59,6 +61,11 @@ bool AppDelegate::initInstance() #endif // CC_PLATFORM_WOPHONE +#if (CC_TARGET_PLATFORM == CC_PLATFORM_AIRPLAY) + // MaxAksenov said it's NOT a very elegant solution. I agree, haha + CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); +#endif + bRet = true; } while (0); return bRet; @@ -71,10 +78,10 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. -// pDirector->enableRetinaDisplay(true); + // pDirector->enableRetinaDisplay(true); // sets landscape mode - pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); + // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // turn on display FPS pDirector->setDisplayFPS(true); diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.h similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/Classes/AppDelegate.h rename to template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.h diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/Classes/HelloWorldScene.cpp rename to template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/Classes/HelloWorldScene.h rename to template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/Prefix.pch b/template/xcode4/cocos2dx_chipmunk.xctemplate/Prefix.pch similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/Prefix.pch rename to template/xcode4/cocos2dx_chipmunk.xctemplate/Prefix.pch diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx_chipmunk.xctemplate/TemplateIcon.icns similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/TemplateIcon.icns rename to template/xcode4/cocos2dx_chipmunk.xctemplate/TemplateIcon.icns diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/ios/AppController.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/ios/AppController.h rename to template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.h diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/ios/AppController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/ios/AppController.mm rename to template/xcode4/cocos2dx_chipmunk.xctemplate/ios/AppController.mm diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/ios/RootViewController.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.h similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/ios/RootViewController.h rename to template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.h diff --git a/template/xcode4/cocos2d_box2d.xctemplate/ios/RootViewController.mm b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm similarity index 87% rename from template/xcode4/cocos2d_box2d.xctemplate/ios/RootViewController.mm rename to template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm index 3de46c4884..b7ad54b327 100644 --- a/template/xcode4/cocos2d_box2d.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/RootViewController.mm @@ -34,9 +34,12 @@ } */ -// Override to allow orientations other than the default portrait orientation. +// Override to allow orientations other than the default landscape orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); + + // switch to this line if you want to set portrait view + // return UIInterfaceOrientationIsPortrait( interfaceOrientation ); } - (void)didReceiveMemoryWarning { diff --git a/template/xcode4/cocos2d_chipmunk.xctemplate/ios/main.m b/template/xcode4/cocos2dx_chipmunk.xctemplate/ios/main.m similarity index 100% rename from template/xcode4/cocos2d_chipmunk.xctemplate/ios/main.m rename to template/xcode4/cocos2dx_chipmunk.xctemplate/ios/main.m diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppController.h b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppController.h new file mode 100644 index 0000000000..03aa6ad390 --- /dev/null +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppController.h @@ -0,0 +1,14 @@ +// +// HelloLuaAppController.h +// HelloLua +// +// Created by Walzer on 11-6-15. +// Copyright __MyCompanyName__ 2011. All rights reserved. +// + +@interface HelloLuaAppController : NSObject { + UIWindow *window; +} + +@end + diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppController.mm b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppController.mm new file mode 100644 index 0000000000..ca0b7b4c59 --- /dev/null +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppController.mm @@ -0,0 +1,97 @@ +// +// HelloLuaAppController.mm +// HelloLua +// +// Created by Walzer on 11-6-15. +// Copyright __MyCompanyName__ 2011. All rights reserved. +// +#import +#import "HelloLuaAppController.h" +#import "cocos2d.h" +#import "EAGLView.h" +#import "AppDelegate.h" + +@implementation HelloLuaAppController + +#pragma mark - +#pragma mark Application lifecycle + +// cocos2d application instance +static AppDelegate s_sharedApplication; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + // Override point for customization after application launch. + + // Add the view controller's view to the window and display. + window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; + EAGLView *__glView = [EAGLView viewWithFrame: [window bounds] + pixelFormat: kEAGLColorFormatRGBA8 + depthFormat: GL_DEPTH_COMPONENT16_OES + preserveBackbuffer: NO + sharegroup: nil + multiSampling: NO + numberOfSamples: 0 ]; + [window addSubview: __glView]; + [window makeKeyAndVisible]; + + [[UIApplication sharedApplication] setStatusBarHidden: YES]; + + cocos2d::CCApplication::sharedApplication().run(); + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + /* + Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + */ + cocos2d::CCDirector::sharedDirector()->pause(); +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + /* + Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + */ + cocos2d::CCDirector::sharedDirector()->resume(); +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + /* + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + If your application supports background execution, called instead of applicationWillTerminate: when the user quits. + */ + cocos2d::CCDirector::sharedDirector()->stopAnimation(); +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + /* + Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. + */ + cocos2d::CCDirector::sharedDirector()->startAnimation(); +} + +- (void)applicationWillTerminate:(UIApplication *)application { + /* + Called when the application is about to terminate. + See also applicationDidEnterBackground:. + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { + /* + Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. + */ +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/main.m b/template/xcode4/cocos2dx_lua.xctemplate/Classes/main.m new file mode 100644 index 0000000000..98908961ce --- /dev/null +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/main.m @@ -0,0 +1,16 @@ +// +// main.m +// HelloLua +// +// Created by Walzer on 11-6-15. +// Copyright __MyCompanyName__ 2011. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) { + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); + [pool release]; + return retVal; +} diff --git a/template/xcode4/cocos2d_lua.xctemplate/Prefix.pch b/template/xcode4/cocos2dx_lua.xctemplate/Prefix.pch old mode 100755 new mode 100644 similarity index 100% rename from template/xcode4/cocos2d_lua.xctemplate/Prefix.pch rename to template/xcode4/cocos2dx_lua.xctemplate/Prefix.pch diff --git a/template/xcode4/cocos2d_lua.xctemplate/Resources/hello.lua b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua similarity index 100% rename from template/xcode4/cocos2d_lua.xctemplate/Resources/hello.lua rename to template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua diff --git a/template/xcode4/cocos2d_lua.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx_lua.xctemplate/TemplateIcon.icns similarity index 100% rename from template/xcode4/cocos2d_lua.xctemplate/TemplateIcon.icns rename to template/xcode4/cocos2dx_lua.xctemplate/TemplateIcon.icns diff --git a/template/xcode4/cocos2d_lua.xctemplate/ios/main.m b/template/xcode4/cocos2dx_lua.xctemplate/ios/main.m similarity index 100% rename from template/xcode4/cocos2d_lua.xctemplate/ios/main.m rename to template/xcode4/cocos2dx_lua.xctemplate/ios/main.m