现在的位置: 首页 > 综合 > 正文

cocos2dx教程之CCMenu

2018年04月22日 ⁄ 综合 ⁄ 共 949字 ⁄ 字号 评论关闭

//用图片来做按钮  

        CCMenuItemImage* myItems = CCMenuItemImage::itemFromNormalImage(           "normal.png", "down.png",  

            this,   

            menu_selector(HelloWorld::myMenuCallback));  

        CC_BREAK_IF(!myItems);  

        myItems->setPosition(ccp(size.width/2, size.height - 50));  

        CCMenu* myMenu = CCMenu::menuWithItems(myItems, NULL);  

        myMenu->setPosition(CCPointZero);  

        CC_BREAK_IF(!myMenu);  

        this->addChild(myMenu, 1);  

 //用文字来做按钮  

        CCLabelTTF* pLabel = CCLabelTTF::labelWithString("sceondMenu", "Arial",40);  

        CCMenuItemLabel* pItemLabel = CCMenuItemLabel::itemWithLabel(pLabel,  

            this, menu_selector(HelloWorld::secondMenuCallback));  

        CCMenu* pSecondMenu = CCMenu::menuWithItems(pItemLabel, NULL);  

        pItemLabel->setPosition(ccp(size.width/2, size.height-150));  

       pSecondMenu->setPosition(CCPointZero);  

          this->addChild(pSecondMenu, 2);  

  

抱歉!评论已关闭.