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


C++ CCMenuItemToggle类代码示例

本文整理汇总了C++中CCMenuItemToggle的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemToggle类的具体用法?C++ CCMenuItemToggle怎么用?C++ CCMenuItemToggle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CCMenuItemToggle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setBackImage

void OptionLayer::setupViews()
{
	//Ìí¼Ó±³¾°Í¼Æ¬
	setBackImage("loading.png");

	CCSprite* pTitle = CCSprite::create("menuTitle.png", CCRectMake(0, 0, 133, 36));
	pTitle->setPosition(ccp(getSize().width/2, getSize().height/2 + 40));
	addChild(pTitle);

	CCMenuItemToggle* pItem = CCMenuItemToggle::create(this, menu_selector(OptionLayer::Music_Func), 
														CCMenuItemFont::create("Music : On"),
														CCMenuItemFont::create("Music : Off"),
														NULL);
	CCMenu* pMenu = CCMenu::create(pItem, NULL);
	pMenu->setPosition(ccp(getSize().width/2, getSize().height/2-20));
	addChild(pMenu);

	if(SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
		pItem->setSelectedIndex(1);
	else
		pItem->setSelectedIndex(0);

	//Ìí¼Ó·µ»Ø°´Å¥
	CCLabelBMFont* pFnt = CCLabelBMFont::create("<--Go Back", "arial-14.fnt");
	CCMenuItemLabel* pLabel = CCMenuItemLabel::create(pFnt, this, menu_selector(OptionLayer::GoBack_Func));
	CCMenu* pMenuBack = CCMenu::create(pLabel, NULL);
	pMenuBack->setPosition(ccp(getSize().width/2, getSize().height/2 - 150));
	addChild(pMenuBack);
	
}
开发者ID:skiing886,项目名称:cocos2dx_2_0_1,代码行数:30,代码来源:OptionLayer.cpp

示例2: setToggleStateByNodeIndex

void IOSStoreLayer::setToggleStateByNodeIndex(int iNodeIndex)
{
	CCMenuItemToggle* pToggle = NULL;
	CCNode* pNode = NULL;
	for (int i = 0; i < 2; ++i)
	{
		pNode = m_pBg->getChildByTag(kaibaoxiang_node_tag+i);
		pToggle = (CCMenuItemToggle*)m_pBgMenu->getChildByTag(kaibaoxiang_toggle_tag+i);
		if (iNodeIndex == i)
		{
			if (pNode)
			{
//				pNode->setVisible(true);
//				this->setTableViewVisble(pNode, (void*)true);
				pToggle->setSelectedIndex(1);
			}
		}
		else
		{
			if (pNode)
			{
//				pNode->setVisible(false);
//				this->setTableViewVisble(pNode, (void*)false);
				pToggle->setSelectedIndex(0);
			}
		}
	}
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:28,代码来源:IOSStoreLayer.cpp

示例3: callbackSwitch

void MailListScene::callbackSwitch(CCObject* pSender){
    
	CCMenuItemToggle* pSwitch = (CCMenuItemToggle*)pSender;
	
	int *idx = (int *)pSwitch->getUserData();
	if (idx==NULL)
	{
		if (pSwitch->getSelectedIndex()==0) {
			for(int i=0;i<mArrayList->count();i++)
			{
				vUserData[i]=0;
			}
		} else {
			for(int i=0;i<mArrayList->count();i++)
			{
				vUserData[i]=1;
			}
		}
		mTableViewMail->refreshData();
	}
	else
	{
		if (pSwitch->getSelectedIndex()==0) {
			*idx = 0;
		} else {
			*idx = 1;
		}
	}
}
开发者ID:crazyit,项目名称:iGame,代码行数:29,代码来源:MailListScene.cpp

示例4: CCMenuItemToggle

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

示例5: connectToSwitch

void NotificationCenterTest::connectToSwitch(CCObject *sender)
{
    CCMenuItemToggle* item = (CCMenuItemToggle*)sender;
    bool bConnected = item->getSelectedIndex() == 0 ? false : true;
    Light* pLight = (Light*)this->getChildByTag(item->getTag()-kTagConnect+kTagLight);
    pLight->setIsConnectToSwitch(bConnected);
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:7,代码来源:NotificationCenterTest.cpp

示例6: ccp

bool PoptipLayer::addButton(const char* normalImage, const char* selectedImage, const char* title, CCPoint &pos, int tag/* = 0*/)
{
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCPoint pCenter = ccp(winSize.width / 2, winSize.height / 2);

	// 创建图片菜单按钮
	CCMenuItemImage *normal = CCMenuItemImage::create(normalImage, normalImage);
	CCMenuItemImage *checked = CCMenuItemImage::create(selectedImage, selectedImage);
	//创建开关按钮选项,并设置回调函数
	CCMenuItemToggle *toggle = CCMenuItemToggle::createWithTarget(this,
		menu_selector(PoptipLayer::buttonCallback),
		normal,
		checked,
		NULL
		);



	toggle->setTag(tag);
	toggle->setPosition(pCenter);

	toggle->setPosition(pos);
	getMenuButton()->addChild(toggle);
	return true;

}
开发者ID:huchenmin,项目名称:cocos2d_project,代码行数:26,代码来源:PoptipLayer.cpp

示例7: va_start

void BaseMenuLayer::addToggleMenuItem(CCArray* pArrayOfItems,SEL_MenuHandler selector,int select,...)
{
    va_list args;
    va_start(args, select);
    CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, selector,  NULL);
    do{
        const char* str = va_arg(args, const char*);
        if(!str) break;
        //CCLabelTTF *label = CCLabelTTF::create(str, "Arial", 24);
        //CCMenuItemLabel *menuitem = CCMenuItemLabel::create(label);
        CCLabelTTF* label = CCLabelTTF::create(str, "Arial", LARGE_FONT_SIZE);
        CCSprite* s = CCSprite::create("Images/button1.png");
        label->setPosition(ccp(s->getContentSize().width/2,s->getContentSize().height/2));
        s->addChild(label);

        CCMenuItemSprite* menuitem = CCMenuItemSprite::create(s, s,s,this, selector);
        item->addSubItem(menuitem);

    }while(true);


    item->setSelectedIndex(select);
    pArrayOfItems->addObject(item);
    va_end(args);
}
开发者ID:MrHantLP,项目名称:Renju,代码行数:25,代码来源:BaseLayer.cpp

示例8: CCLog

void IOSStoreLayer::clickToggleCallBack(CCObject* pObj)
{
	CCLog("menutoggle call back");
	CCMenuItemToggle* pToggle = (CCMenuItemToggle*)pObj;
	int iTag = pToggle->getTag();
	int index = pToggle->getSelectedIndex();
	switch (iTag)
	{
	case kaibaoxiang_toggle_tag:
		{
			m_iCurShowNodeIndex = kaibaoxiang_node_index;

			if (m_enumComeFrom == from_GameInSuperTool)
			{
				this->setComefrom(m_enumComeFrom);
			}
			else if (m_enumComeFrom == from_SeasonSelector)
			{
				this->setComefrom(m_enumComeFrom);
			}
			else if (m_enumComeFrom == from_MarketStore)
			{
				this->setComefrom(m_enumComeFrom);
			}
			else if (m_enumComeFrom == from_GameInHelpMap)
			{
				this->setTipBgVisible(true);
			}
			this->setLeftTopTipStrVisible(true);
			this->setADVisible(false);
		}
		break;

	case buystar_toggle_tag:
		{
			m_iCurShowNodeIndex = buystar_node_index;
			this->setLeftTopTipStrVisible(false);
			this->setTipBgVisible(false);
			this->setADVisible(true);
		}
		break;

	default:
		break;
	}
	
	this->setToggleStateByNodeIndex(m_iCurShowNodeIndex);

	if (index == 1)
	{
		if (m_iCurShowNodeIndex == buystar_node_index)
		{
			this->replaceLayer(m_pKaibaoxiangNode, m_pBuyStarNode, this, SEL_CallFuncN(&IOSStoreLayer::setTableViewVisble));
		}
		else
		{
			this->replaceLayer(m_pBuyStarNode, m_pKaibaoxiangNode, this, SEL_CallFuncN(&IOSStoreLayer::setTableViewVisble));
		}
	}
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:60,代码来源:IOSStoreLayer.cpp

示例9: toggleDetail

void MyBuildingCard::toggleDetail(cocos2d::CCNode *pSender) {
    CCMenuItemToggle* toggle = ((CCMenuItemToggle*)pSender);
    if(toggle->getSelectedIndex() == 1) {
        displayDetail(pSender);
    } else {
        cancelDetail(pSender);
    }
}
开发者ID:itita,项目名称:2-z-q-x-,代码行数:8,代码来源:MyBuildingCard.cpp

示例10: createButton

void PauseLayer::addObjectiveLayer() {
    objectiveLayer = CCLayer::create();
    objectiveLayer->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
    float scale = Utility::isIPad() ? 1 : 0.8;
    CCLabelBMFont *labelObj = CCLabelBMFont::create("objectives", kFontChubby, 0);
    labelObj->setPosition(ccp(winSize.width * 0, winSize.height * 0.45));
    labelObj->setScale(scale);
    objectiveLayer->addChild(labelObj, 2);
    
    createButton("btnStats.png", 5, ccp(winSize.width * 0.3, winSize.height * 0.93));
    
    int j = 0;
        arrayForActive = CCArray::create();
    for (int i = 1; i <= 41; i++) {
        //        int level = 40 - i;
        
        if (Utility::getAchievementStatus(i) == 1) {
            arrayForActive->insertObject(CCString::createWithFormat("%d", i), j);
            j++;
            if (j == 3) {
                break;
            }
        }
    }
    
    for (int i = 0; i < arrayForActive->count(); i++) {
        CCSprite *objective = CCSprite::createWithSpriteFrameName(kScrollBar);
        objective->setPositionY(winSize.height * kScrollBarGap * i - winSize.height * 0.2);
        
        CCString *string = (CCString*)arrayForActive->objectAtIndex(i);
        int level = string->intValue();
        CCString *obj_1 = (CCString*) Utility::objectiveDict()->valueForKey(CCString::createWithFormat("kAchievement_%d_0", level)->getCString());
        CCString *obj_2 = (CCString*) Utility::objectiveDict()->valueForKey(CCString::createWithFormat("kAchievement_%d_1", level)->getCString());
        createLabel(obj_1->getCString(), obj_2->getCString(), ccp(objective->getContentSize().width * 0.18, objective->getContentSize().height * 0.85), objective);
        createSprite("iconTrophy.png", ccp(objective->getContentSize().width * 0.03, objective->getContentSize().height * 0.85), objective);
        objectiveLayer->addChild(objective, 2);
    }
    addChild(objectiveLayer, 2);
    arrayForActive->removeAllObjects();
    arrayForActive->release();
    
    
    soundOn = CCSprite::createWithSpriteFrameName("btnSoundOn.png");
    menuItemSoundOn = CCMenuItemSprite::create(soundOn, soundOn, this, menu_selector(PauseLayer::soundsButtonTapped));
    menuItemSoundOn->setTag(1);
    
    soundOff = CCSprite::createWithSpriteFrameName("btnSoundOff.png");
    menuItemSoundOff = CCMenuItemSprite::create(soundOff, soundOff, this, menu_selector(PauseLayer::soundsButtonTapped));
    menuItemSoundOff->setTag(2);
    
    CCMenuItemToggle *toggleSound = CCMenuItemToggle::createWithTarget(this, menu_selector(PauseLayer::soundsButtonTapped), menuItemSoundOn, menuItemSoundOff, NULL);
    toggleSound->setSelectedIndex((CCUserDefault::sharedUserDefault()->getBoolForKey(kSoundsKey) ? 0 : 1));
    
    menuSoundOff = CCMenu::create(toggleSound , NULL);
    menuSoundOff->setPosition(ccp(winSize.width * 0.95, winSize.height * 0.92));
    addChild(menuSoundOff, 2);
}
开发者ID:ashtonjohnson,项目名称:testing_games,代码行数:57,代码来源:PauseLayer.cpp

示例11: CCLog

void MallMarkets::menuItemCall(cocos2d::CCObject *pSender)
{
    CCMenuItemToggle *temp = (CCMenuItemToggle*)pSender;
    CCLog("getTag :%d",temp->getTag());

   
    //PropMarketsLayer *layerMarket = NULL;
    if (!layerMarket) {
        layerMarket = PropMarketsLayer::create();
        this->addChild(layerMarket, 1);
    }
    layerMarket->setTag(1135);
    
    
    //fubi = server  prop = player
    if (((CCMenuItemToggle*)pSender)->getTag() == 1122) {
        
        if (togglePlayer->getSelectedIndex() == 1) {
            togglePlayer->setSelectedIndex(0);
          
            this->getChildByTag(1135)->setVisible(false);
            this->getChildByTag(1136)->setVisible(true);
            toggleServer->setEnabled(false);
            togglePlayer->setEnabled(true);
        }
        else{
            togglePlayer->setSelectedIndex(1);
            
            this->getChildByTag(1135)->setVisible(true);
            this->getChildByTag(1136)->setVisible(false);
        }
        
    }
    
    //prop = player   fubi = server
    if (((CCMenuItemToggle*)pSender)->getTag() == 1133) {
        
        if (toggleServer->getSelectedIndex() == 1) {
            
            toggleServer->setSelectedIndex(0);
            this->getChildByTag(1135)->setVisible(false);
            this->getChildByTag(1136)->setVisible(true);
        }
        else{
            
            toggleServer->setSelectedIndex(1);
            toggleServer->setEnabled(true);
            togglePlayer->setEnabled(false);
        
            this->getChildByTag(1135)->setVisible(true);
            this->getChildByTag(1136)->setVisible(false);
            
        }
        
    }
    
}
开发者ID:valentman,项目名称:Shoot,代码行数:57,代码来源:MallMarkets.cpp

示例12: callbackSwitch

void ChatLayer::callbackSwitch(CCObject* pSender){
    
	CCMenuItemToggle* pSwitch = (CCMenuItemToggle*)pSender;
    
    if (pSwitch->getSelectedIndex()==0) {
        m_blnRememberMe = false;
    } else {
        m_blnRememberMe = true;
    }
}
开发者ID:crazyit,项目名称:iGame,代码行数:10,代码来源:ChatLayer.cpp

示例13: va_start

	CCMenuItemToggle * CCMenuItemToggle::itemWithTarget(SelectorProtocol* target, SEL_MenuHandler selector, CCMenuItem* item, ...)
	{
		va_list args;
		va_start(args, item);
		CCMenuItemToggle *pRet = new CCMenuItemToggle();
		pRet->initWithTarget(target, selector, item, args);
		pRet->autorelease();
		va_end(args);
		return pRet;
	}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:10,代码来源:CCMenuItem.cpp

示例14: musicMenuCallback

void ConfigMenu::musicMenuCallback( CCObject* sender )
{
	CCMenuItemToggle* target = (CCMenuItemToggle*) sender;
	int item = target->getSelectedIndex();//item为0时,当前背景音乐是关闭的;
	if(item==0){
		GameManager::getInstance()->playerBackgroundMusic();
	}else{
		GameManager::getInstance()->stopBackgroundMusic();
	}
}
开发者ID:laogong5i0,项目名称:MiniGame,代码行数:10,代码来源:ConfigMenu.cpp

示例15: soundsButtonTapped

void  PauseLayer::soundsButtonTapped(CCObject *sender) {
    CCUserDefault *defaults = CCUserDefault::sharedUserDefault();
    CCMenuItemToggle *toggleItem = (CCMenuItemToggle*)sender;
    if (toggleItem->selectedItem() == menuItemSoundOn) {
        defaults->setBoolForKey(kSoundsKey, true);
        Utility::changeVolume(1.0f);
    } else if (toggleItem->selectedItem() == menuItemSoundOff) {
        defaults->setBoolForKey(kSoundsKey, false);
        Utility::changeVolume(0.0f);
    }
}
开发者ID:ashtonjohnson,项目名称:testing_games,代码行数:11,代码来源:PauseLayer.cpp


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