本文整理汇总了C++中CCMenuItem类的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItem类的具体用法?C++ CCMenuItem怎么用?C++ CCMenuItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCLOG
void MenuLayerMainMenu::menuCallback(CCObject* pSender)
{
CCLOG("menuCallback called");
// get the userdata, it's the index of the menu item clicked
CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
int nIdx = pMenuItem->getZOrder() - 1000;
// create the test scene and run it
switch (nIdx)
{
case 1:
{
CCLOG("new game clicked");
CCScene* scene=CCScene::create();
CCLayer* layer=MenuLayerPlayerSelect::create();
scene->addChild(layer,0);
CCDirector::sharedDirector()->pushScene(CCTransitionSlideInT::create(1,scene));
break;
}
case 2:
CCLOG("load game clicked");
break;
case 6:
CCDirector::sharedDirector()->end();
default:
break;
}
}
示例2: onButtonClick
void LayerMoney::onButtonClick(CCObject* pSender)
{
CCMenuItem* mnu = (CCMenuItem*)pSender;
int tag = mnu->getTag();
if( currTag == tag )
return;
//
switch (tag) {
case tag_ChargeDisable:
currTag = tag_ChargeEnable;
gotoChargeMoney();
break;
case tag_HistoryDisable:
currTag = tag_HistoryEnable;
gotoHistory();
break;
case tag_TransferDisable:
currTag = tag_TransferEnable;
gotoTransfer("");
break;
case tag_LoanDisable:
currTag = tag_LoanEnable;
gotoBorrow();
break;
case tag_ExchangeDisable:
currTag = tag_ExchangeEnable;
gotoExchange();
break;
}
disableTabs(currTag);
CCLOG("onButtonClick with tag: %d", tag);}
示例3: addChild
void FriendInvitationLayer::showInvitationCode(const char *invitationCode) {
CCSprite *spInvitationBg = CCSprite::spriteWithFile("invitation_bg.png");
spInvitationBg->setPosition(CCPointMake(320, 440));
addChild(spInvitationBg);
CCSprite *tempSprite1 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png");
CCSprite *tempSprite2 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png");
CCMenuItem *menuItemSina = CCMenuItemImage::itemFromNormalSprite(tempSprite1,
tempSprite2,
this,
menu_selector(FriendInvitationLayer::inviteFriendFromWeibo));
menuItemSina->setAnchorPoint(CCPointMake(0, 0));
CCMenu *menu = CCMenu::menuWithItem(menuItemSina);
menu->setPosition(CCPointMake(280, 505));
addChild(menu);
if(CGameData::Inst()->getLoginType() == enLoginReqType_TencentLogin){
menuItemSina ->setIsVisible(CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
}else if(CGameData::Inst()->getLoginType() == enLoginReqType_SinaLogin){
menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
}else {
menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg|CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
}
TextNode *lbInvitationCode = TextNode::textWithString(invitationCode, CCSizeMake(500, 40), CCTextAlignmentLeft, 32);
lbInvitationCode->setColor(ccRED);
lbInvitationCode->setPosition(CCPointMake(550, 646));
addChild(lbInvitationCode);
}
示例4: CCARRAY_FOREACH
CCMenuItem* CPullMachMenu::itemForTouchPM(CCTouch * touch)
{
CCPoint touchLocation = touch->getLocation();
if (m_pChildren && m_pChildren->count() > 0)
{
CCObject* pObject = NULL;
CCARRAY_FOREACH(m_pChildren, pObject)
{
CCMenuItem* pChild = dynamic_cast<CCMenuItem*>(pObject);
if (pChild && pChild->isVisible() && pChild->isEnabled())
{
CCPoint local = pChild->convertToNodeSpace(touchLocation);
CCRect r;
r.size = pChild->getContentSize();
r.origin.x = r.size.width * 0.2f;
r.size.width *= 0.6f;
r.origin.y = r.size.height * 0.2f;
r.size.height *= 0.8f;
if (r.containsPoint(local))
{
return pChild;
}
}
}
示例5: dispatchTutorialMsg
bool UIScrollPage::dispatchTutorialMsg(CCObject* pObject,unsigned int type)
{
UIMenu* menu = NULL;
CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(pObject);
if(menuItem)
{
CCNode* node = menuItem->getParent();
menu = dynamic_cast<UIMenu*>(node);
}
else
{
menu = dynamic_cast<UIMenu*>(pObject);
}
if(menu)
{
CCNode* parent = menu->getParent();
IconButton* button = dynamic_cast<IconButton*>(parent);
char name[50];
sprintf(name,"%s_%d",this->m_strName.c_str(),button->GetButtonIndex());
return TutorialsManager::Get()->HandleOneEvent(name,type);
}
return true;
}
示例6: CCMenuItem
CCMenuItem* CCMenuItem::create(CCObject *rec, SEL_MenuHandler selector)
{
CCMenuItem *pRet = new CCMenuItem();
pRet->initWithTarget(rec, selector);
pRet->autorelease();
return pRet;
}
示例7: CCPoint
LayerLevels::LayerLevels()
{
CCPoint* offset = new CCPoint(180, 180);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
CCMenuItemSprite* level = CCMenuItemSprite::create(
CCSprite::createWithSpriteFrameName("btn_level1.png"),
CCSprite::createWithSpriteFrameName("btn_level2.png"),
this, menu_selector(LayerLevels::click_level));
CCMenu* menu = CCMenu::createWithItem(level);
menu->setPosition(CCDirector::sharedDirector()->convertToUI(
ccp(offset->x + 200* i, offset->y + 85 * j)));
this->addChild(menu);
char str[64] = {0};
sprintf(str, "%d", (j * 4 + i + 1));
CCMenuItem* menuitem = new CCMenuItem();
CCLabelTTF* text = CCLabelTTF::create(
str, "Arial", 22);
text->setColor(ccBLACK);
menuitem->addChild(text);
menu->addChild(menuitem);
}
}
}
示例8: onDialog
void RPGStartSceneLayer::onDialog(cocos2d::CCObject *pObject)
{
SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
CCMenuItem *menuItem = (CCMenuItem*)pObject;
switch (menuItem->getTag())
{
case kRPGStartSceneLayerTagDialogCancel:
{
this->removeChildByTag(kRPGStartSceneLayerTagDialog, true);
CCMenu *mainMenu = (CCMenu*)this->getChildByTag(kRPGStartSceneLayerTagMainMenu);
mainMenu->setEnabled(true);
}
break;
default:
{
//kRPGStartSceneLayerTagMenuItemDialogOK
//清除数据
this->m_db.execDML("delete from save_data");
this->m_db.execDML("delete from items_existing");
this->m_db.execDML(GAME_INIT_SQL);
//默认设置
CCUserDefault::sharedUserDefault()->setStringForKey(GAME_STYLE, this->m_styleData[1].first);
this->goToMapScene();
}
break;
}
}
示例9: onButtonClick
void LayerFriend::onButtonClick(CCObject* pSender)
{
CCMenuItem* mnu = (CCMenuItem*)pSender;
int tag = mnu->getTag();
if( currTag == tag )
return;
//
switch (tag) {
case tag_friendInfoDisable:
currTag = tag_friendInfoEnable;
gotoFriendDetails();
//
break;
case tag_inviteDisable:
// CCNodeLoaderLibrary* ccNodeLoaderLibrary = SceneManager::getSingleton().getNodeLoaderLibrary();
// CCBReader* ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
// ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
// LayerInviteFriends* mLayer;
// if (ccbReader)
// {
// mLayer = (LayerInviteFriends *)ccbReader->readNodeGraphFromFile( "LayerInviteFriends.ccbi" );
// this->addChild(mLayer, 1, 1);
// ccbReader->release();
// }
//
gotoInviteFriends();
//return;
currTag = tag_inviteEnable;
break;
}
disableTabs(currTag);
CCLOG("onButtonClick with tag: %d", tag);}
示例10: onClickedOneSever
void FrontCoverLayer::onClickedOneSever(CCObject* pSender)
{
CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(pSender);
if(menuItem)
{
CCNode* node = menuItem->getParent();
CCMenu* menu = dynamic_cast<CCMenu*>(node);
if(menu)
{
CCNode* parent = menu->getParent();
IconButton* button = dynamic_cast<IconButton*>(parent);
if(button)
{
int buttonIndex = button->GetButtonIndex();
// to do
SeverInfo* info = m_severList[buttonIndex];
if(info)
{
USERINFO data = UserData::GetUserInfo();
sprintf(data.ip,"%s",info->severIp);
sprintf(data.lastServerName,"%s",info->name);
data.port = info->port;
UserData::SetUserInfo(data);
//onCLickedSeverCloseBt(pSender);
XLogicManager::sharedManager()->logIn();
}
}
}
}
}
示例11:
//设置按钮显示
void CStar97UILayer::setBtnVisible(enGameBtnTag eBtnTag, bool bVisible)
{
CCMenuItem * pItem = dynamic_cast<CCMenuItem *>(m_pMenuLayer->getChildByTag(eBtnTag));
CCAssert(pItem != NULL, "this tag button don't have");
if (pItem->isVisible() != bVisible)
pItem->setVisible(bVisible);
}
示例12: onPressCityBtn
void CityListLayer::onPressCityBtn(CCObject* sender)
{
if (playerMoving)
{
return;
}
CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(sender);
if(menuItem)
{
CCNode* node = menuItem->getParent();
CCMenu* menu = dynamic_cast<CCMenu*>(node);
if(menu)
{
CCNode* parent = menu->getParent();
IconButton* button = dynamic_cast<IconButton*>(parent);
if(button)
{
playerMoving = true;
int index = button->GetButtonIndex();
targetCityId = cityInfoList[index - 1].cityId;
moveToCity(targetCityId, 0);
}
}
}
}
示例13: addChild
//------------------------------------------------------------------
//
// NodeToWorld
//
//------------------------------------------------------------------
NodeToWorld::NodeToWorld()
{
//
// This code tests that nodeToParent works OK:
// - It tests different anchor Points
// - It tests different children anchor points
CCSprite *back = CCSprite::spriteWithFile(s_back3);
addChild( back, -10);
back->setAnchorPoint( CCPointMake(0,0) );
CCSize backSize = back->getContentSize();
CCMenuItem *item = CCMenuItemImage::itemFromNormalImage(s_PlayNormal, s_PlaySelect);
CCMenu *menu = CCMenu::menuWithItems(item, NULL);
menu->alignItemsVertically();
menu->setPosition( CCPointMake(backSize.width/2, backSize.height/2));
back->addChild(menu);
CCActionInterval* rot = CCRotateBy::actionWithDuration(5, 360);
CCAction* fe = CCRepeatForever::actionWithAction( rot);
item->runAction( fe );
CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(200,0));
CCActionInterval* move_back = move->reverse();
CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
CCAction* fe2 = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
back->runAction(fe2);
}
示例14: addChild
//------------------------------------------------------------------
//
// NodeToWorld
//
//------------------------------------------------------------------
NodeToWorld::NodeToWorld()
{
//
// This code tests that nodeToParent works OK:
// - It tests different anchor Points
// - It tests different children anchor points
CCSprite *back = CCSprite::create(s_back3);
addChild( back, -10);
back->setAnchorPoint( ccp(0,0) );
CCSize backSize = back->getContentSize();
CCMenuItem *item = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect);
CCMenu *menu = CCMenu::create(item, NULL);
menu->alignItemsVertically();
menu->setPosition( ccp(backSize.width/2, backSize.height/2));
back->addChild(menu);
CCActionInterval* rot = CCRotateBy::create(5, 360);
CCAction* fe = CCRepeatForever::create( rot);
item->runAction( fe );
CCActionInterval* move = CCMoveBy::create(3, ccp(200,0));
CCActionInterval* move_back = move->reverse();
CCSequence* seq = CCSequence::create( move, move_back, NULL);
CCAction* fe2 = CCRepeatForever::create(seq);
back->runAction(fe2);
}
示例15: addMenu
void MapMenu::addMenu()
{
if (spriteBackButton != NULL) {
spriteBackButton->removeFromParentAndCleanup(false);
}
spriteBackButton = CCSprite::create("Background_Estacionamento_botoes.png");
spriteBackButton->setAnchorPoint(ccp(0, 0));
CCSize winsize = CCDirector::sharedDirector()->getWinSize();
if (winsize.height > 480) {
spriteBackButton->setPosition(ccp(0, 430));
}
else
{
spriteBackButton->setPosition(ccp(0, 350));
}
layer->addChild(spriteBackButton, 100) ;
CCMenuItem *pOpenMapItem;
CCMenuItem *pOpen3DItem;
if(type == MAP_NORMAL )
{
pOpenMapItem = CCMenuItemImage::create("button_comochegar_pressed.png","button_comochegar_pressed.png",this,menu_selector(MapMenu::openMap));
pOpen3DItem = CCMenuItemImage::create("button_3d_on.png","button_3d_on.png",this,menu_selector(MapMenu::open3D));
}
else
{
pOpenMapItem = CCMenuItemImage::create("button_comochegar_on.png","button_comochegar_on.png",this,menu_selector(MapMenu::openMap));
pOpen3DItem = CCMenuItemImage::create("button_3d_pressed.png","button_3d_pressed.png",this,menu_selector(MapMenu::open3D));
}
pOpenMapItem->setAnchorPoint(ccp(0, 0));
pOpenMapItem->setPosition(ccp(0, 0));
pOpen3DItem->setAnchorPoint(ccp(0, 0));
pOpen3DItem->setPosition(ccp(110, 00));
// pCloseItem->setFontSize(35);
// pCloseItem->setFontName("Helvetica");
if (menu != NULL) {
menu->removeFromParentAndCleanup(false);
}
menu = CCMenu::create(pOpenMapItem,pOpen3DItem,NULL);
menu->setAnchorPoint(ccp(0, 0));
if (winsize.height > 480) {
menu->setPosition(ccp(50, 450));
}
else
{
menu->setPosition(ccp(50, 360));
}
layer->addChild(menu,101);
}