Пример #1
0
//图鉴内容开关
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);
	}


}
Пример #2
0
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;
    }
}
Пример #3
0
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();
    }
}
Пример #4
0
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);
	}
}
Пример #5
0
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);
	}
}
Пример #6
0
void UIButtonTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
{
    MenuItemToggle *item = (MenuItemToggle*)pSender;

    switch (item->getSelectedIndex())
    {
    case 0:
    {
        _layout->removeFromParentAndCleanup(true);

        _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIButton/windows_UIButton_Editor_1.json"));
        _touchGroup->addChild(_layout);

        this->configureGUIScene();

        break;
    }

    case 1:
    {
        _layout->removeFromParentAndCleanup(true);

        _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIButton/windows_UIButton_Editor_1.csb"));
        _touchGroup->addChild(_layout);

        this->configureGUIScene();

        break;
    }

    case 2:
    {
        _layout->removeFromParentAndCleanup(true);

        Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIButton_Editor/crossplatform_UIButton_Editor_1.ExportJson");
        Node* child = node->getChildByTag(4);
        child->removeFromParent();
        _layout = static_cast<Layout*>(child);
        _touchGroup->addChild(_layout);

        this->configureGUIScene();

        break;
    }

    case 3:
    {
        _layout->removeFromParentAndCleanup(true);

        Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIButton_Editor/crossplatform_UIButton_Editor_1.csb");
        Node* child = node->getChildByTag(4);
        child->removeFromParent();
        _layout = static_cast<Layout*>(child);
        _touchGroup->addChild(_layout);

        this->configureGUIScene();

        break;
    }

    default:
        break;
    }
}
Пример #7
0
//属性,图鉴,技能 开关
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);
			auto menuMove = MoveBy::create(0.5, Vec2(-vSize.width / 5, 0));
			menuBG->runAction(menuMove);
		}
	}

	if (t->getName() == "skill") {
		if (t->getSelectedIndex() == 1 && characterToggle->getSelectedIndex() == 0 && illustratedHhandbookToggle->getSelectedIndex() == 0) {

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

		}
		if (t->getSelectedIndex() == 1 && (characterToggle->getSelectedIndex() == 1 || illustratedHhandbookToggle->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 skillMove = MoveBy::create(0.5, Vec2(-vSize.width / 4.8, 0));
				skill->setVisible(true);
				skill->runAction(skillMove);

			}
			if (illustratedHhandbookToggle->getSelectedIndex() == 1) {
				illustratedHhandbookToggle->setSelectedIndex(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);
				auto skillMove = MoveBy::create(0.5, Vec2(-vSize.width / 4.8, 0));
				skill->setVisible(true);
				skill->runAction(skillMove);
			}

		}
		if (t->getSelectedIndex() == 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 menuMove = MoveBy::create(0.5, Vec2(-vSize.width / 5, 0));
			menuBG->runAction(menuMove);
		}
	}



}