diff --git a/template/multi-platform-cpp/Classes/AppDelegate.cpp b/template/multi-platform-cpp/Classes/AppDelegate.cpp index 27677ac1ad..41659181d6 100644 --- a/template/multi-platform-cpp/Classes/AppDelegate.cpp +++ b/template/multi-platform-cpp/Classes/AppDelegate.cpp @@ -13,8 +13,8 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director* director = Director::getInstance(); - EGLView* eglView = EGLView::getInstance(); + auto director = Director::getInstance(); + auto eglView = EGLView::getInstance(); director->setOpenGLView(eglView); @@ -25,7 +25,7 @@ bool AppDelegate::applicationDidFinishLaunching() { director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object - Scene *scene = HelloWorld::scene(); + auto scene = HelloWorld::createScene(); // run director->runWithScene(scene); diff --git a/template/multi-platform-cpp/Classes/HelloWorldScene.cpp b/template/multi-platform-cpp/Classes/HelloWorldScene.cpp index c2f4896258..9c6f231620 100644 --- a/template/multi-platform-cpp/Classes/HelloWorldScene.cpp +++ b/template/multi-platform-cpp/Classes/HelloWorldScene.cpp @@ -2,13 +2,13 @@ USING_NS_CC; -Scene* HelloWorld::scene() +Scene* HelloWorld::createScene() { // 'scene' is an autorelease object - Scene *scene = Scene::create(); + auto scene = Scene::create(); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::create(); + auto layer = HelloWorld::create(); // add layer as a child to scene scene->addChild(layer); @@ -35,16 +35,16 @@ bool HelloWorld::init() // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object - MenuItemImage *closeItem = MenuItemImage::create( - "CloseNormal.png", - "CloseSelected.png", - CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); + auto closeItem = MenuItemImage::create( + "CloseNormal.png", + "CloseSelected.png", + CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2 , origin.y + closeItem->getContentSize().height/2)); // create menu, it's an autorelease object - Menu* menu = Menu::create(closeItem, NULL); + auto menu = Menu::create(closeItem, NULL); menu->setPosition(Point::ZERO); this->addChild(menu, 1); @@ -54,7 +54,7 @@ bool HelloWorld::init() // add a label shows "Hello World" // create and initialize a label - LabelTTF* label = LabelTTF::create("Hello World", "Arial", 24); + auto label = LabelTTF::create("Hello World", "Arial", 24); // position the label on the center of the screen label->setPosition(Point(origin.x + visibleSize.width/2, @@ -64,7 +64,7 @@ bool HelloWorld::init() this->addChild(label, 1); // add "HelloWorld" splash screen" - Sprite* sprite = Sprite::create("HelloWorld.png"); + auto sprite = Sprite::create("HelloWorld.png"); // position the sprite on the center of the screen sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); diff --git a/template/multi-platform-cpp/Classes/HelloWorldScene.h b/template/multi-platform-cpp/Classes/HelloWorldScene.h index 45139f9d67..79ce38afea 100644 --- a/template/multi-platform-cpp/Classes/HelloWorldScene.h +++ b/template/multi-platform-cpp/Classes/HelloWorldScene.h @@ -6,16 +6,16 @@ class HelloWorld : public cocos2d::Layer { public: + // there's no 'id' in cpp, so we recommend returning the class instance pointer + static cocos2d::Scene* createScene(); + // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone virtual bool init(); - - // there's no 'id' in cpp, so we recommend returning the class instance pointer - static cocos2d::Scene* scene(); // a selector callback void menuCloseCallback(Object* pSender); - // implement the "static node()" method manually + // implement the "static create()" method manually CREATE_FUNC(HelloWorld); }; diff --git a/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj b/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj index 5bfab9fd8f..66e87292fc 100644 --- a/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj +++ b/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj @@ -372,7 +372,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0430; + LastUpgradeCheck = 0500; }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloCpp" */; compatibilityVersion = "Xcode 3.2"; @@ -572,7 +572,6 @@ CLANG_CXX_LIBRARY = "libc++"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COMPRESS_PNG_FILES = NO; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; @@ -626,7 +625,6 @@ CLANG_CXX_LIBRARY = "libc++"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COMPRESS_PNG_FILES = NO; COPY_PHASE_STRIP = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -673,11 +671,12 @@ C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COMPRESS_PNG_FILES = NO; GCC_C_LANGUAGE_STANDARD = c99; GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; VALID_ARCHS = "armv6 armv7 i386"; }; @@ -686,7 +685,7 @@ C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COMPRESS_PNG_FILES = NO; GCC_C_LANGUAGE_STANDARD = c99; GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; diff --git a/template/multi-platform-cpp/proj.mac/HelloCpp.xcodeproj/project.pbxproj b/template/multi-platform-cpp/proj.mac/HelloCpp.xcodeproj/project.pbxproj index da9efca126..cb196c341a 100644 --- a/template/multi-platform-cpp/proj.mac/HelloCpp.xcodeproj/project.pbxproj +++ b/template/multi-platform-cpp/proj.mac/HelloCpp.xcodeproj/project.pbxproj @@ -362,7 +362,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0430; + LastUpgradeCheck = 0500; }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloCpp" */; compatibilityVersion = "Xcode 3.2"; @@ -572,11 +572,11 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; @@ -620,11 +620,11 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -664,11 +664,11 @@ C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; VALID_ARCHS = "x86_64 i386"; }; @@ -677,7 +677,6 @@ C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES;