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


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

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


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

示例1: fieldGuideInformati

//图鉴内容开关
void HeroInformationMenuLayer::fieldGuideInformati(Ref *sender){
	MenuItemToggle * t = (MenuItemToggle *)sender;
	if (t->getSelectedIndex() == 1) {
		t->setEnabled(false);
		illustratedHhandbook->setZOrder(100);
		auto fieldImage = t->getSubItems().at(0);
		auto fieldGuideMove = MoveBy::create(0.5, Vec2(vSize.width / 5, 0));
		auto fieldGuideRotation = RotateBy::create(0.5, -90);
		auto fieldGuideScale = ScaleBy::create(0.5, vSize.width / (fieldImage->getContentSize().width * 2));
		auto fieldGuideCall = CallFunc::create([=](){
			t->setEnabled(true);
		});
		auto seqAction = Spawn::create(fieldGuideMove, fieldGuideRotation, fieldGuideScale, NULL);
		auto sequenceAC = Sequence::create(seqAction, fieldGuideCall, NULL);
		t->runAction(sequenceAC);
	}
	if (t->getSelectedIndex() == 0) {
		t->setEnabled(false);
		auto fieldImage = t->getSubItems().at(0);
		float scale = vSize.width / (fieldImage->getContentSize().width * 2);
		auto fieldGuideMove = MoveBy::create(0.5, Vec2(-vSize.width / 5, 0));
		auto fieldGuideRotation = RotateBy::create(0.5, 90);
		auto fieldGuideScale = ScaleBy::create(0.5, fieldImage->getContentSize().width / (fieldImage->getContentSize().width * scale));
		auto spaAction = Spawn::create(fieldGuideMove, fieldGuideRotation, fieldGuideScale, NULL);
		auto callAction = CallFunc::create([=](){
			illustratedHhandbook->setZOrder(0);
			t->setEnabled(true);
		});
		auto seqAction = Sequence::create(spaAction, callAction, NULL);
		t->runAction(seqAction);
	}


}
开发者ID:joyfish,项目名称:TowerTD,代码行数:35,代码来源:HeroInformationMenuLayer.cpp

示例2: menuMusicToggleCallback

void TopMenu::menuMusicToggleCallback(Ref* pSender)
{
    MenuItemToggle* menuMusic = (MenuItemToggle*)pSender;
    
    CCLOG("selected index:%d",menuMusic->getSelectedIndex());
    
    int select = menuMusic->getSelectedIndex();
    
    switch (select) {
        case 0:
        {
            Audio::getInstance()->setbIsOpenMusic(true);
            Audio::getInstance()->playBGM();
        }
            break;
        case 1:
        {
            Audio::getInstance()->setbIsOpenMusic(false);
            Audio::getInstance()->pauseBGM();
        }
            break;
            
        default:
            break;
    }
}
开发者ID:chosener,项目名称:PopStar,代码行数:26,代码来源:TopMenu.cpp

示例3: switchLoadMethod

void UIListViewTest_Vertical_Editor::switchLoadMethod(cocos2d::Ref *pSender)
{
    MenuItemToggle *item = (MenuItemToggle*)pSender;
    
    if (item->getSelectedIndex() == 0){
        _layout->removeFromParentAndCleanup(true);
        
        _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.json"));
        _touchGroup->addChild(_layout);
        
        this->configureGUIScene();
    }else{
        _layout->removeFromParentAndCleanup(true);
        
        _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.csb"));
        _touchGroup->addChild(_layout);
        
        this->configureGUIScene();
    }
}
开发者ID:AppleJDay,项目名称:cocos2d-x,代码行数:20,代码来源:UIListViewTest_Editor.cpp

示例4: SwitchAudio

void Pause::SwitchAudio(Ref *Sender)
{
	//this code makes sure that music is being enabled when needed and disabled properly
    MusicD& md=MusicD::getHandle();

	MenuItemToggle *toggleItem = (MenuItemToggle *)Sender;

	if(toggleItem->getSelectedIndex()==0)
	{
		CocosDenshion::SimpleAudioEngine::getInstance()->resumeAllEffects();
		md.SetIsAudioPlaying(true);
		md.SetShouldAudioPlay(false);
	}
	else
	{
		CocosDenshion::SimpleAudioEngine::getInstance()->stopAllEffects();
		md.SetIsAudioPlaying(false);
		md.SetShouldAudioPlay(false);
	}
}
开发者ID:Stedke,项目名称:Android-game-cocos2d-x,代码行数:20,代码来源:Pause.cpp

示例5: SwitchMusic

void Pause::SwitchMusic(Ref *Sender)
{
	//this code makes sure that audio is being enabled when needed and disabled properly
    MusicD& md=MusicD::getHandle();

	MenuItemToggle *toggleItem = (MenuItemToggle *)Sender;

	if(toggleItem->getSelectedIndex()==0)
	{
		if(!md.GetIsMusicPlaying())
		{
			CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("Music.mp3",true);
		}

		md.SetIsMusicPlaying(true);
		md.SetShouldMusicPlay(false);
	}
	else
	{
		CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic();
		md.SetIsMusicPlaying(false);
		md.SetShouldMusicPlay(false);
	}
}
开发者ID:Stedke,项目名称:Android-game-cocos2d-x,代码行数:24,代码来源:Pause.cpp

示例6: toggleButton

//属性,图鉴,技能 开关
void HeroInformationMenuLayer::toggleButton(Ref * sender){
	MenuItemToggle * t = (MenuItemToggle *)sender;
	if (t->getName() == "character") {
		if (t->getSelectedIndex() == 1 && illustratedHhandbookToggle->getSelectedIndex() == 0 && skillToggle->getSelectedIndex() == 0) {

			auto characterMove = MoveBy::create(0.5, Vec2(-vSize.width / 4.8, 0));
			character->setVisible(true);
			character->runAction(characterMove);
			auto menuMove = MoveBy::create(0.5, Vec2(vSize.width / 5, 0));
			menuBG->runAction(menuMove);

		}
		if (t->getSelectedIndex() == 1 && (illustratedHhandbookToggle->getSelectedIndex() == 1 || skillToggle->getSelectedIndex() == 1)) {

			if (illustratedHhandbookToggle->getSelectedIndex() == 1) {
				illustratedHhandbookToggle->setSelectedIndex(0);
				auto illustratedHhandebookMove = MoveBy::create(0.5, Vec2(vSize.width / 5, 0));
				auto callVisibile = CallFunc::create([=](){
					illustratedHhandbook->setVisible(false);
				});
				auto seqAction = Sequence::create(illustratedHhandebookMove, callVisibile, NULL);
				illustratedHhandbook->runAction(seqAction);
				auto characterMove = MoveBy::create(0.5, Vec2(-vSize.width / 4.8, 0));
				character->setVisible(true);
				character->runAction(characterMove);

			}
			if (skillToggle->getSelectedIndex() == 1) {
				skillToggle->setSelectedIndex(0);
				auto skillMove = MoveBy::create(0.5, Vec2(vSize.width / 4.8, 0));
				auto callVisibile = CallFunc::create([=](){
					skill->setVisible(false);
				});
				auto seqAction = Sequence::create(skillMove, callVisibile, NULL);
				skill->runAction(seqAction);
				auto characterMove = MoveBy::create(0.5, Vec2(-vSize.width / 4.8, 0));
				character->setVisible(true);
				character->runAction(characterMove);
			}

		}
		if (t->getSelectedIndex() == 0) {
			auto characterMove = MoveBy::create(0.5, Vec2(vSize.width / 4.8, 0));
			auto callVisibile = CallFunc::create([=](){
				character->setVisible(false);
			});
			auto seqAction = Sequence::create(characterMove, callVisibile, NULL);
			character->runAction(seqAction);
			auto menuMove = MoveBy::create(0.5, Vec2(-vSize.width / 5, 0));
			menuBG->runAction(menuMove);
		}
	}

	if (t->getName() == "illustratedHhandbook") {
		if (t->getSelectedIndex() == 1 && characterToggle->getSelectedIndex() == 0 && skillToggle->getSelectedIndex() == 0) {

			auto illustratedMove = MoveBy::create(0.5, Vec2(-vSize.width / 5, 0));
			illustratedHhandbook->setVisible(true);
			illustratedHhandbook->runAction(illustratedMove);
			auto menuMove = MoveBy::create(0.5, Vec2(vSize.width / 5, 0));
			menuBG->runAction(menuMove);

		}
		if (t->getSelectedIndex() == 1 && (characterToggle->getSelectedIndex() == 1 || skillToggle->getSelectedIndex() == 1)) {

			if (characterToggle->getSelectedIndex() == 1) {
				characterToggle->setSelectedIndex(0);
				auto characterMove = MoveBy::create(0.5, Vec2(vSize.width / 4.8, 0));
				auto callVisibile = CallFunc::create([=](){
					character->setVisible(false);
				});
				auto seqAction = Sequence::create(characterMove, callVisibile, NULL);
				character->runAction(seqAction);
				auto illustratedMove = MoveBy::create(0.5, Vec2(-vSize.width / 5, 0));
				illustratedHhandbook->setVisible(true);
				illustratedHhandbook->runAction(illustratedMove);

			}
			if (skillToggle->getSelectedIndex() == 1) {
				skillToggle->setSelectedIndex(0);
				auto skillMove = MoveBy::create(0.5, Vec2(vSize.width / 4.8, 0));
				auto callVisibile = CallFunc::create([=](){
					skill->setVisible(false);
				});
				auto seqAction = Sequence::create(skillMove, callVisibile, NULL);
				skill->runAction(seqAction);
				auto illustratedMove = MoveBy::create(0.5, Vec2(-vSize.width / 5, 0));
				illustratedHhandbook->setVisible(true);
				illustratedHhandbook->runAction(illustratedMove);
			}

		}
		if (t->getSelectedIndex() == 0) {
			auto illustratedMove = MoveBy::create(0.5, Vec2(vSize.width / 5, 0));
			auto callVisibile = CallFunc::create([=](){
				illustratedHhandbook->setVisible(false);
			});
			auto seqAction = Sequence::create(illustratedMove, callVisibile, NULL);
			illustratedHhandbook->runAction(seqAction);
//.........这里部分代码省略.........
开发者ID:joyfish,项目名称:TowerTD,代码行数:101,代码来源:HeroInformationMenuLayer.cpp


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