Exit Button;

1、、、、、、、、、、、、

// 5. add exit Button
CCSprite* exitBtnN = CCSprite::create("arsenal_ui_main.png",CCRectMake(700, 80, 128, 128));
CCSprite* exitBtnP = CCSprite::create("arsenal_ui_main.png",CCRectMake(700, 208, 128, 128));
CCMenuItemSprite* uiExitBtn = CCMenuItemSprite::create(
            exitBtnN,
exitBtnP,
            exitBtnN,
            this,
            menu_selector(ArsenalScene::arsenalExitCallback));
uiExitBtn->setPosition(ccp( size.width-uiExitBtn->getContentSize().width/2,uiExitBtn->getContentSize().height/2 ));

//

// Create a menu with the all buttons, it's an auto release object.
CCMenu* uiMenu = CCMenu::create(uiExitBtn,  NULL);
uiMenu->setPosition(CCPointZero);
this->addChild(uiMenu, 2);


void ArsenalScene::arsenalExitCallback(CCObject* pSender)
{
if( !btnPressed )
{
btnPressed = true;
if(RD_ISSOUND_ON)
{
/*SimpleAudioEngine::sharedEngine()->playEffect
(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("sound_btn_click.mp3"));*/
SimpleAudioEngine::sharedEngine()->playEffect("sound_btn_click.mp3");
}
CCScene *pScene = MenuScene::scene();
CCDirector::sharedDirector()->replaceScene(pScene);
}
}




你可能感兴趣的:(Exit Button;)