一、图片类菜单
1.创建一个图片菜单选项,回调函数要一个参"cocos2d::Ref* pSender"
MenuItemImage *quitItem = MenuItemImage::create("Buttons/quitButton.png", "Buttons/quitButtonSelect.png", CC_CALLBACK_1(HelloWorld::QuitItemCallback, this));
2.用这个图片菜单选项创建一个菜单
Menu *menu_6 = Menu::create(quitItem, NULL);
3,设置菜单位置
menu_6->setPosition(Vec2(550,700));
4.将菜单添加到当前层
this->addChild(menu_6);
二、标签菜单
1.创建一个标签
Label *ifPlayMusic = Label::createWithTTF("Music", "fonts/Marker Felt.ttf", 24);
2.用这个标签创建一个标签选项,回调函数用0,代表回调函数需要传0个参数.
MenuItemLabel *ifPlayMusic_MIL = MenuItemLabel::create(ifPlayMusic, CC_CALLBACK_0(HelloWorld::ifCloseMusic,this));
3.设置标签位置
ifPlayMusic_MIL->setPosition(Vec2(950, 700));
4.用这个标签选项创建一个菜单
Menu *menu_7 = Menu::create(ifPlayMusic_MIL, NULL);
5.设置菜单位置为ZERO.
menu_7->setPosition(Vec2::ZERO);
6.将这个菜单添加到当前层
this->addChild(menu_7);