Small fixes for Xcode templates

Also, uses `auto` in the template code to be more c++11 friendly
This commit is contained in:
Ricardo Quesada 2013-09-18 16:50:26 -07:00
parent fa71f8f479
commit 24df87265e
5 changed files with 25 additions and 27 deletions

View File

@ -13,8 +13,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching() { bool AppDelegate::applicationDidFinishLaunching() {
// initialize director // initialize director
Director* director = Director::getInstance(); auto director = Director::getInstance();
EGLView* eglView = EGLView::getInstance(); auto eglView = EGLView::getInstance();
director->setOpenGLView(eglView); director->setOpenGLView(eglView);
@ -25,7 +25,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
director->setAnimationInterval(1.0 / 60); director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object // create a scene. it's an autorelease object
Scene *scene = HelloWorld::scene(); auto scene = HelloWorld::createScene();
// run // run
director->runWithScene(scene); director->runWithScene(scene);

View File

@ -2,13 +2,13 @@
USING_NS_CC; USING_NS_CC;
Scene* HelloWorld::scene() Scene* HelloWorld::createScene()
{ {
// 'scene' is an autorelease object // 'scene' is an autorelease object
Scene *scene = Scene::create(); auto scene = Scene::create();
// 'layer' is an autorelease object // 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create(); auto layer = HelloWorld::create();
// add layer as a child to scene // add layer as a child to scene
scene->addChild(layer); scene->addChild(layer);
@ -35,7 +35,7 @@ bool HelloWorld::init()
// you may modify it. // you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object // add a "close" icon to exit the progress. it's an autorelease object
MenuItemImage *closeItem = MenuItemImage::create( auto closeItem = MenuItemImage::create(
"CloseNormal.png", "CloseNormal.png",
"CloseSelected.png", "CloseSelected.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
@ -44,7 +44,7 @@ bool HelloWorld::init()
origin.y + closeItem->getContentSize().height/2)); origin.y + closeItem->getContentSize().height/2));
// create menu, it's an autorelease object // create menu, it's an autorelease object
Menu* menu = Menu::create(closeItem, NULL); auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Point::ZERO); menu->setPosition(Point::ZERO);
this->addChild(menu, 1); this->addChild(menu, 1);
@ -54,7 +54,7 @@ bool HelloWorld::init()
// add a label shows "Hello World" // add a label shows "Hello World"
// create and initialize a label // 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 // position the label on the center of the screen
label->setPosition(Point(origin.x + visibleSize.width/2, label->setPosition(Point(origin.x + visibleSize.width/2,
@ -64,7 +64,7 @@ bool HelloWorld::init()
this->addChild(label, 1); this->addChild(label, 1);
// add "HelloWorld" splash screen" // 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 // position the sprite on the center of the screen
sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

View File

@ -6,16 +6,16 @@
class HelloWorld : public cocos2d::Layer class HelloWorld : public cocos2d::Layer
{ {
public: 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 // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init(); virtual bool init();
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* scene();
// a selector callback // a selector callback
void menuCloseCallback(Object* pSender); void menuCloseCallback(Object* pSender);
// implement the "static node()" method manually // implement the "static create()" method manually
CREATE_FUNC(HelloWorld); CREATE_FUNC(HelloWorld);
}; };

View File

@ -372,7 +372,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = { 29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0430; LastUpgradeCheck = 0500;
}; };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloCpp" */; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloCpp" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
@ -572,7 +572,6 @@
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COMPRESS_PNG_FILES = NO;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
@ -626,7 +625,6 @@
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COMPRESS_PNG_FILES = NO;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -673,11 +671,12 @@
C01FCF4F08A954540054247B /* Debug */ = { C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; COMPRESS_PNG_FILES = NO;
GCC_C_LANGUAGE_STANDARD = c99; GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = ""; GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
VALID_ARCHS = "armv6 armv7 i386"; VALID_ARCHS = "armv6 armv7 i386";
}; };
@ -686,7 +685,7 @@
C01FCF5008A954540054247B /* Release */ = { C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; COMPRESS_PNG_FILES = NO;
GCC_C_LANGUAGE_STANDARD = c99; GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = ""; GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;

View File

@ -362,7 +362,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = { 29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0430; LastUpgradeCheck = 0500;
}; };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloCpp" */; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloCpp" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
@ -572,11 +572,11 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
@ -620,11 +620,11 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -664,11 +664,11 @@
C01FCF4F08A954540054247B /* Debug */ = { C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
GCC_C_LANGUAGE_STANDARD = c99; GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = ""; GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx; SDKROOT = macosx;
VALID_ARCHS = "x86_64 i386"; VALID_ARCHS = "x86_64 i386";
}; };
@ -677,7 +677,6 @@
C01FCF5008A954540054247B /* Release */ = { C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
GCC_C_LANGUAGE_STANDARD = c99; GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = ""; GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;