刚接触到cocos2d-x3.2版本,发现3.x与2.x版本有很大差别,看下面一段代码
- auto closeItem = MenuItemImage::create(
- "CloseNormal.png","CloseSelected.png",CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
我们明显发现,多了一个 自动类型变量auto,同时,由CCMenuItemImage变成了MenuItemImage。
我们在这里改一下:
编译运行程序,编译通过,我们知道,cocos2dx3.0配合c11标准,使得代码逻辑更加紧凑。
- auto closeItem = MenuItemImage::create(
- "CloseNormal.png",[](Object *sender)
- {
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
- MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
- return;
- #endif
- Director::getInstance()->end();
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
- exit(0);
- #endif
- });