TP:68D951F8
大致来看,从左往右分别是文字菜单,精灵菜单,切换菜单
//字体菜单
LabelTTF * menettf = LabelTTF::create("hello", "fonts / arial.ttf", 50);
MenuItemLabel *labelitem = MenuItemLabel::create(
menettf,this,menu_selector(HelloWorld::menuCloseCallback));
labelitem->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
//字符标签菜单
MenuItemFont *fontitem = MenuItemFont::create(
"Menu",this, menu_selector(HelloWorld::menuCloseCallback));
fontitem->setPosition(ccp(200, 200));
//图片菜单
MenuItemImage* imgitem = MenuItemImage::create(
"CloseSelected.png","CloseNormal.png",this, menu_selector(HelloWorld::menuCloseCallback));
imgitem->setPosition(ccp(visibleSize.width -20, 20));
//精灵菜单
auto on = Sprite::create("buttonon.png");
auto off = Sprite::create("buttonoff.png");
MenuItemSprite* spriteitem = MenuItemSprite::create(
on, off, this, menu_selector(HelloWorld::menuCloseCallback)
);
spriteitem->setPosition(ccp(100, 200));
//切换菜单
MenuItemToggle *toggle = MenuItemToggle::createWithTarget(
this, menu_selector(HelloWorld::menuCloseCallback),
MenuItemFont::create("On"), MenuItemFont::create("Off"),NULL
);
toggle->setPosition(ccp(300, 300));
Menu* menu = Menu::create(labelitem,fontitem,imgitem,spriteitem,toggle,NULL);
menu->setPosition(Vec2(0,0));
this->addChild(menu);