当前位置: 首页>>代码示例>>C++>>正文


C++ CCMenuItem类代码示例

本文整理汇总了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;
	}
}
开发者ID:yxf006,项目名称:coco-project,代码行数:34,代码来源:MenuLayerMainMenu.cpp

示例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);}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:31,代码来源:LayerMoney.cpp

示例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);
}
开发者ID:haoliumilan,项目名称:AgainstSango,代码行数:33,代码来源:FriendInvitationLayer.cpp

示例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;
				}
			}
		}
开发者ID:hantingmeixue,项目名称:Aoyi,代码行数:26,代码来源:PullMachMenu.cpp

示例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;
	}
开发者ID:niuzb,项目名称:hellopet,代码行数:25,代码来源:UIScrollPage.cpp

示例6: CCMenuItem

CCMenuItem* CCMenuItem::create(CCObject *rec, SEL_MenuHandler selector)
{
    CCMenuItem *pRet = new CCMenuItem();
    pRet->initWithTarget(rec, selector);
    pRet->autorelease();
    return pRet;
}
开发者ID:fordream,项目名称:quick,代码行数:7,代码来源:CCMenuItem.cpp

示例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);
		}
	}
}
开发者ID:jonesgithub,项目名称:dotawar,代码行数:27,代码来源:LayerLevels.cpp

示例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;
    }
}
开发者ID:jonesgithub,项目名称:OzgGameRPG,代码行数:33,代码来源:RPGStartSceneLayer.cpp

示例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);}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:32,代码来源:LayerFriend.cpp

示例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();
				}
			}
		}
	}
}
开发者ID:niuzb,项目名称:hellopetclient,代码行数:30,代码来源:FrontCoverLayer.cpp

示例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);
}
开发者ID:hantingmeixue,项目名称:Aoyi,代码行数:8,代码来源:Star97UILayer.cpp

示例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);
							
			}
		}
	}
}
开发者ID:niuzb,项目名称:hellopetclient,代码行数:28,代码来源:CityListLayer.cpp

示例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);
}
开发者ID:issamux,项目名称:WebGame,代码行数:33,代码来源:CocosNodeTest.cpp

示例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);
}
开发者ID:HongXiao,项目名称:Client-source,代码行数:33,代码来源:NodeTest.cpp

示例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);
}
开发者ID:rossimrc,项目名称:AlbertEinstein,代码行数:60,代码来源:MapMenu.cpp


注:本文中的CCMenuItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。