cocos2dx教程之CCMenu

//用圖片來做按鈕  

        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);  

  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章