各种CCMenu的使用

CCLabelTTF//字体按钮









 



CCLabelTTF *pLabel2 =CCLabelTTF::create("开始游戏", "Thonburi", 24);



    CCMenuItemLabel*item=CCMenuItemLabel::create(pLabel2, this,menu_selector(HelloWorld::menuCloseCallback));



    CCLabelTTF *pLabel3 =CCLabelTTF::create("游戏暂定", "Thonburi", 24);



    CCMenuItemLabel*item1=CCMenuItemLabel::create(pLabel3, this,menu_selector(HelloWorld::menuCloseCallback));



    item1->setPosition(pLabel2->getPositionX(), pLabel2->getPositionY()+30);



    CCMenu* pMenu = CCMenu::create(item,item1, NULL);



    pMenu->setPosition(200, 100);



    this->addChild(pMenu, 1);



 



 



CCMenuItemImage//图片按钮 自带dome中有的按钮



 









 



    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(



                                        "CloseNormal.png",



                                        "CloseSelected.png",



                                        this,



                                        menu_selector(HelloWorld::menuCloseCallback) );



    pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );



 



    // create menu, it's an autorelease object



    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);



    pMenu->setPosition( CCPointZero );



    this->addChild(pMenu, 1);



 

CCMenuItemSprite//sprite1按钮 搞不懂 跟CCMenuItemImage有什么功能性的区别





    CCSprite*sprite1=CCSprite::create("52design.com_kr_001.png");



    CCSprite*sprite2=CCSprite::create("52design.com_kr_001.png");



    CCMenuItemSprite*itemSprit=CCMenuItemSprite::create(sprite1, sprite2, this,menu_selector(HelloWorld::menuCloseCallback));



    



    CCSprite*sprite3=CCSprite::create("52design.com_kr_004.png");



    CCSprite*sprite4=CCSprite::create("52design.com_kr_004.png");



    CCMenuItemSprite*itemSprit1=CCMenuItemSprite::create(sprite3, sprite4, this,menu_selector(HelloWorld::menuCloseCallback));



    itemSprit1->setPosition(itemSprit->getPositionX()+130, itemSprit->getPositionY());



    CCMenu* pMenu = CCMenu::create(itemSprit,itemSprit1, NULL);



    pMenu->setPosition(ccp(70, size.height/2));



    this->addChild(pMenu);

 

 

你可能感兴趣的:(menu)