auto closeItem = MenuItemImage::create( "CloseNormal.png","CloseSelected.png",CC_CALLBACK_1(HelloWorld::menuCloseCallback,this)); closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2,origin.y + closeItem->getContentSize().height/2)); auto menu = Menu::create(closeItem,NULL); menu->setPosition(Vec2::ZERO); this->addChild(menu,1);
MenuItemLabel创建
auto start_game = MenuItemLabel::create( Label::createWithTTF("StartGame","fonts/Marker Felt.ttf",30),this,menu_selector(HelloWorld::menuCloseCallback)); auto start_menu = Menu::create(start_game,NULL); this->addChild(start_menu);
MenuItemFont创建
auto new_game = MenuItemFont::create("NewGame",menu_selector(HelloWorld::menuCloseCallback)); auto game_menu = Menu::create(new_game,NULL); new_game->setPosition(visibleSize.width / 4,visibleSize.height / 2); this->addChild(new_game);
MenuItemSprite创建
auto sprite_menu = MenuItemSprite::create( Sprite::create("ButtonStar.png"),Sprite::create("ButtonStarSel.png"),this)); auto menu_star = Menu::create(sprite_menu,NULL); menu_star->setPosition(visibleSize.width / 8,visibleSize.height / 2); this->addChild(menu_star);