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


C++ CCMenuItemToggle::getSelectedIndex方法代码示例

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


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

示例1: 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

示例2: clickToggleCallBack

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

示例3: 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

示例4: 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

示例5: addChild

NotificationCenterTest::NotificationCenterTest()
: m_bShowImage(false)
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
        menu_selector(NotificationCenterTest::toExtensionsMainLayer));
    pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
    CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
    pBackMenu->setPosition( CCPointZero );
    addChild(pBackMenu);

    CCLabelTTF *label1 = CCLabelTTF::create("switch off", "Marker Felt", 26);
    CCLabelTTF *label2 = CCLabelTTF::create("switch on", "Marker Felt", 26);
    CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
    CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
    CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL);
    // turn on
    item->setSelectedIndex(1);
    CCMenu *menu = CCMenu::create(item, NULL);
    menu->setPosition(ccp(s.width/2+100, s.height/2));
    addChild(menu);

    CCMenu *menuConnect = CCMenu::create();
    menuConnect->setPosition(CCPointZero);
    addChild(menuConnect);

    for (int i = 1; i <= 3; i++)
    {
        Light* light = Light::lightWithFile("Images/Pea.png");
        light->setTag(kTagLight+i);
        light->setPosition(ccp(100, s.height/4*i));
        addChild(light);

        CCLabelTTF *label1 = CCLabelTTF::create("not connected", "Marker Felt", 26);
        CCLabelTTF *label2 = CCLabelTTF::create("connected", "Marker Felt", 26);
        CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
        CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
        CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL);
        item->setTag(kTagConnect+i);
        item->setPosition(ccp(light->getPosition().x, light->getPosition().y+50));
        menuConnect->addChild(item, 0);
        if (i == 2)
        {
            item->setSelectedIndex(1);
        }
        bool bConnected = item->getSelectedIndex() == 1 ? true : false;
        light->setIsConnectToSwitch(bConnected);
    }

    CCNotificationCenter::sharedNotificationCenter()->postNotification(MSG_SWITCH_STATE, (CCObject*)(intptr_t)item->getSelectedIndex());

    /* for testing removeAllObservers */
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(NotificationCenterTest::doNothing), "random-observer1", NULL);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(NotificationCenterTest::doNothing), "random-observer2", NULL);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(NotificationCenterTest::doNothing), "random-observer3", NULL);
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:57,代码来源:NotificationCenterTest.cpp

示例6: 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

示例7: 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

示例8: getMusicState

void MenuLayer::getMusicState(CCObject* pSender){
	if (signIn->isVisible() || !canStartGame || signInPrize->isVisible()){
		return;
	}
	Audio::getInstance()->playSound("Music/paddle_hit.wav");

	CCMenuItemToggle* temp = (CCMenuItemToggle*)pSender;

	if (temp->getSelectedIndex() == 1)
	{

		CocosDenshion::SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
		GAMEDATA::getInstance()->setMusicState(false);
	}
	if (temp->getSelectedIndex() == 0)
	{

		CocosDenshion::SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
		GAMEDATA::getInstance()->setMusicState(true);
	}
}
开发者ID:joyfish,项目名称:cocos2d,代码行数:21,代码来源:MenuLayer.cpp

示例9: addChild

NotificationCenterTest::NotificationCenterTest()
: m_bShowImage(false)
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCMenuItemFont* pBackItem = CCMenuItemFont::itemFromString("Back", this,
        menu_selector(NotificationCenterTest::toExtensionsMainLayer));
    pBackItem->setPosition(ccp(s.width - 50, 25));
    CCMenu* pBackMenu = CCMenu::menuWithItems(pBackItem, NULL);
    pBackMenu->setPosition( CCPointZero );
    addChild(pBackMenu);

    CCLabelTTF *label1 = CCLabelTTF::labelWithString("switch off", "Marker Felt", 26);
    CCLabelTTF *label2 = CCLabelTTF::labelWithString("switch on", "Marker Felt", 26);
    CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1);
    CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2);
    CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL);
    // turn on
    item->setSelectedIndex(1);
    CCMenu *menu = CCMenu::menuWithItems(item, NULL);
    menu->setPosition(ccp(s.width/2+100, s.height/2));
    addChild(menu);

    CCMenu *menuConnect = CCMenu::menuWithItems(NULL);
    menuConnect->setPosition(CCPointZero);
    addChild(menuConnect);

    for (int i = 1; i <= 3; i++)
    {
        Light* light = Light::lightWithFile("Images/Pea.png");
        light->setTag(kTagLight+i);
        light->setPosition(ccp(100, s.height/4*i));
        addChild(light);

        CCLabelTTF *label1 = CCLabelTTF::labelWithString("not connected", "Marker Felt", 26);
        CCLabelTTF *label2 = CCLabelTTF::labelWithString("connected", "Marker Felt", 26);
        CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1);
        CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2);
        CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL);
        item->setTag(kTagConnect+i);
        item->setPosition(ccp(light->getPosition().x, light->getPosition().y+50));
        menuConnect->addChild(item, 0);
        if (i == 2)
        {
            item->setSelectedIndex(1);
        }
        bool bConnected = item->getSelectedIndex() == 1 ? true : false;
        light->setIsConnectToSwitch(bConnected);
    }

    CCNotificationCenter::sharedNotifCenter()->postNotification(MSG_SWITCH_STATE, (CCObject*)item->getSelectedIndex());
}
开发者ID:AfterTheRainOfStars,项目名称:cocos2d-x-qt,代码行数:52,代码来源:NotificationCenterTest.cpp

示例10: switchLoadMethod

// UILabelBMFontTest_Editor
void UILabelBMFontTest_Editor::switchLoadMethod(cocos2d::CCObject *pSender)
{
    CCMenuItemToggle *item = (CCMenuItemToggle*)pSender;
    if (item->getSelectedIndex() == 0){
        _layout->removeFromParentAndCleanup(true);
        
        _layout = static_cast<Layout*>(GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
        _touchGroup->addWidget(_layout);
        
        this->configureGUIScene();
    }else{
        _layout->removeFromParentAndCleanup(true);
        
        _layout = static_cast<Layout*>(GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.csb"));
        _touchGroup->addWidget(_layout);
        
        this->configureGUIScene();
    }
}
开发者ID:fuguelike,项目名称:cocos2d-x,代码行数:20,代码来源:UILabelBMFontTest_Editor.cpp

示例11: difficultyToggle

KDvoid OptionsMenu::difficultyToggle ( CCObject* pSender )
{
	CCMenuItemToggle*		pItem = (CCMenuItemToggle*) pSender;
	m_pMessage->setString ( ccszf ( "Selected Difficulty Index:%d", pItem->getSelectedIndex ( ) ) );
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:5,代码来源:Ch5_UsingCCMenu.cpp

示例12: toggleSwitch

void NotificationCenterTest::toggleSwitch(CCObject *sender)
{
    CCMenuItemToggle* item = (CCMenuItemToggle*)sender;
    int index = item->getSelectedIndex();
    CCNotificationCenter::sharedNotificationCenter()->postNotification(MSG_SWITCH_STATE, (CCObject*)(intptr_t)index);
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:6,代码来源:NotificationCenterTest.cpp


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