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


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

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


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

示例1: new

MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, const Vector<MenuItem*>& menuItems)
{
    MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
    ret->MenuItem::initWithCallback(callback);
    ret->_subItems = menuItems;
    ret->_selectedIndex = UINT_MAX;
    ret->setSelectedIndex(0);
    return ret;
}
开发者ID:Ratel13,项目名称:WarriorQuest,代码行数:9,代码来源:CCMenuItem.cpp

示例2: MenuItemToggle

MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, Array* menuItems)
{
    MenuItemToggle *pRet = new MenuItemToggle();
    pRet->MenuItem::initWithCallback(callback);
    pRet->_subItems = Array::create();
    pRet->_subItems->retain();

    for (unsigned int z=0; z < menuItems->count(); z++)
    {
        MenuItem* menuItem = (MenuItem*)menuItems->objectAtIndex(z);
        pRet->_subItems->addObject(menuItem);
    }

    pRet->_selectedIndex = UINT_MAX;
    pRet->setSelectedIndex(0);
    return pRet;
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:17,代码来源:CCMenuItem.cpp

示例3: new

MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, const Vector<MenuItem*>& menuItems)
{
    MenuItemToggle *ret = new (std::nothrow) MenuItemToggle();
    ret->MenuItem::initWithCallback(callback);
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
    auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
    if (sEngine)
    {
        for (const auto &item : menuItems)
        {
            if (item)
            {
                sEngine->retainScriptObject(ret, item);
            }
        }
    }
#endif // CC_ENABLE_GC_FOR_NATIVE_OBJECTS
    ret->_subItems = menuItems;
    ret->_selectedIndex = UINT_MAX;
    ret->setSelectedIndex(0);
    return ret;
}
开发者ID:jun496276723,项目名称:CocosMFCEditor,代码行数:22,代码来源:CCMenuItem.cpp

示例4: init

bool StartScene::init()
{
	if ( !Layer::init() )
	{
		return false;
	}
	//加载游戏场景中的资源
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("material_info.plist");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("task_title.plist");

	Audio::getInstance()->playBGM(BACKGORUNDMUSIC);
	Size visibleSize = Director::getInstance()->getVisibleSize();

	Sprite* gamebg = Sprite::create("game_bg.png");
	gamebg->setAnchorPoint(ccp(0.5,0.5));
	gamebg->setPosition(ccp(visibleSize.width/2,visibleSize.height/2));
	this->addChild(gamebg,-1);

	Sprite* boy = Sprite::create("game_start_boy.png");
	boy->setPosition(ccp(570,280));
	this->addChild(boy,1);

	Sprite* title = Sprite::create("game_title.png");
	title->setAnchorPoint(ccp(0,1));
	title->setPosition(ccp(10,380));
	this->addChild(title,2);

	Sprite* clock = Sprite::create("game_clock.png");
	clock->setPosition(ccp(85,135));
	this->addChild(clock);

	Sprite* star1 = Sprite::create("game_star.png");
	star1->setPosition(ccp(50,60));
	RotateBy* rotate = RotateBy::create(6,360);
	star1->runAction(RepeatForever::create(rotate));
	this->addChild(star1);

	Sprite* star2 = Sprite::create("game_star.png");
	star2->setPosition(ccp(600,100));
	ScaleTo* scale1 = ScaleTo::create(1,0.8);
	ScaleTo* scale2 = ScaleTo::create(1,1.0);
	Sequence* seq = Sequence::create(scale1,scale2,NULL);
	star2->runAction(RepeatForever::create(seq));
	this->addChild(star2);

	BlinkTitle* btitle = BlinkTitle::create("start_game_txt.png");;
	btitle->setPosition(visibleSize.width/2,100);
	this->addChild(btitle,2); 

	MenuItemImage* start = MenuItemImage::create("start_game_txt.png","start_game_txt.png",CC_CALLBACK_0(StartScene::startGame,this));
	Menu* menu = Menu::create(start,NULL);
	menu->setPosition(ccp(visibleSize.width/2,100));
	this->addChild(menu,1);

	MenuItemImage* musicBtnOn = MenuItemImage::create("bg_music_open.png","bg_music_open.png");
	MenuItemImage* musicBtnOff = MenuItemImage::create("bg_music_close.png","bg_music_close.png");
	MenuItemToggle* musicTog = MenuItemToggle::createWithTarget(this,menu_selector(StartScene::getMusicState),musicBtnOn,musicBtnOff,NULL);
	if (GAMEDATA::getInstance()->getMusicState())
	{
		musicTog->setSelectedIndex(0);
	}
	else
	{
		musicTog->setSelectedIndex(1);
	}
	Menu* musicMenu = Menu::create(musicTog,NULL);
	musicMenu->setPosition(745,450);
	this->addChild(musicMenu);

	helpButton = nullptr;
	MenuItemImage* helpItem = MenuItemImage::create("help.png","help.png",CC_CALLBACK_0(StartScene::showHelpView,this));
	Menu* help = Menu::create(helpItem,NULL);
	help->setPosition(685,450);
	this->addChild(help);

	MenuItemImage* image = MenuItemImage::create("more_game.png","more_game.png",CC_CALLBACK_0(StartScene::showMoreGame,this));
	moreGame = Menu::create(image, nullptr);
	moreGame->setPosition(720, 40);
	this->addChild(moreGame);
	moreGame->setVisible(false);
	schedule(schedule_selector(StartScene::updateScene), 1.0f, kRepeatForever,0);

#if(CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)
	//签到没有东西可送先关闭
	/*if(!CallAndroidMethod::getInstance()->isSignToday()){
	SignIn* sg = SignIn::getInstance();
	sg->setAnchorPoint(ccp(0.5,0.5));
	this->addChild(sg,3);
	}else{
	schedule(schedule_selector(StartScene::autoStartGame), 3.0f, 0, 0);
	}*/
#endif
	auto listener = EventListenerKeyboard::create();
	listener->onKeyReleased = [=](EventKeyboard::KeyCode code, Event * e){
		switch (code)
		{
		case cocos2d::EventKeyboard::KeyCode::KEY_NONE:
			break;
		case cocos2d::EventKeyboard::KeyCode::KEY_BACK:
			//quitDialog->setVisible(true);
//.........这里部分代码省略.........
开发者ID:joyfish,项目名称:cocos2d,代码行数:101,代码来源:StartScene.cpp

示例5: init


//.........这里部分代码省略.........
	auto quitLayer = QuitLayer::create();
	quitLayer->setTag(1008);
	quitLayer->setVisible(false);
	this->addChild(quitLayer, 30);


	auto listener = EventListenerKeyboard::create();
	listener->onKeyReleased = [=](EventKeyboard::KeyCode code, Event * e){
		switch (code)
		{
		case cocos2d::EventKeyboard::KeyCode::KEY_NONE:
			break;
		case cocos2d::EventKeyboard::KeyCode::KEY_BACK:
			showQuit();
			break;
		default:
			break;
		}
	};

	Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);

	signIn = SignIn::create();
	signIn->setVisible(false);
	this->addChild(signIn, 100);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
	canStartGame = true;
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)	
	if(GAMEDATA::getInstance()->isHasPaySignIn()){
		if(CallAndroidMethod::getInstance()->isSignToday()){
			canStartGame = true;
		}else{
			Audio::getInstance()->playSound("Music/sign_in.ogg");
			signIn->setVisible(true);
			canStartGame = true;
		}
	}else{
		if(!GAMEDATA::getInstance()->getHasShowSignInPay() && !CallAndroidMethod::getInstance()->isHasShowSignInPay()){
			CallAndroidMethod::getInstance()->pay(8);
			GAMEDATA::getInstance()->setHasShowSignInPay(true);
		}else{
			canStartGame = true;
		}
	}
#endif

	auto moreGameBtn = MenuItemImage::create(
		"more_game_btn_normal.png", "more_game_btn_click.png", CC_CALLBACK_0(MenuLayer::showMoreGame, this)
		);
	moreGameMenu = Menu::create(moreGameBtn, NULL);
	moreGameMenu->setPosition(740, 65);
	moreGameMenu->setAnchorPoint(Point(0.5, 0.5));
	moreGameMenu->setVisible(false);
	this->addChild(moreGameMenu);

	Audio::getInstance()->playBGM("Music/lobby_bg.ogg");

	MenuItemImage* musicBtnOn = MenuItemImage::create("bg_music_open.png", "bg_music_open.png");
	MenuItemImage* musicBtnOff = MenuItemImage::create("bg_music_close.png", "bg_music_close.png");
	MenuItemToggle* musicTog = MenuItemToggle::createWithTarget(this, menu_selector(MenuLayer::getMusicState), musicBtnOn, musicBtnOff, NULL);
	if (CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
	{
		musicTog->setSelectedIndex(0);
	}
	else
	{
		musicTog->setSelectedIndex(1);
	}
	auto musicMenu = Menu::create(musicTog, NULL);
	musicMenu->setPosition(60, 65);
	MenuItemImage* soundEffectOn = MenuItemImage::create("sound_effect_open.png", "sound_effect_open.png");
	MenuItemImage* soundEffectOff = MenuItemImage::create("sound_effect_close.png", "sound_effect_close.png");
	MenuItemToggle* soundEffectTog = MenuItemToggle::createWithTarget(this, menu_selector(MenuLayer::getSoudState), soundEffectOn, soundEffectOff, NULL);
	if (GAMEDATA::getInstance()->getSoundState())
	{
		soundEffectTog->setSelectedIndex(0);
	}
	else
	{
		soundEffectTog->setSelectedIndex(1);
	}
	auto soundEffectMenu = Menu::create(soundEffectTog, NULL);
	soundEffectMenu->setPosition(130, 65);
	this->addChild(musicMenu);
	this->addChild(soundEffectMenu);

	signInPrize = SignInPrize::create();
	this->addChild(signInPrize, 200);
	signInPrize->setVisible(false);

	//if (GAMEDATA::getInstance()->isFirstLogin() && Player::skillState <= 4){
		//GAMEDATA::getInstance()->setFirstLogin(false);
		//GameStateInfo::getInstance()->setGameState(Game_Pause);
		//CallAndroidMethod::getInstance()->pay(1);
	//}

	this->scheduleUpdate();
	return true;
}
开发者ID:joyfish,项目名称:cocos2d,代码行数:101,代码来源:MenuLayer.cpp

示例6: init

bool Developer::init()
{
	if( !Layer::init() ){
		return false;
	}

	UserDefault *defaults  = UserDefault::getInstance();
	
	// 添加背景图片
    auto sprite = Sprite::create("scene_abo.png");
	sprite->setPosition(Point(GAME_SCREEN_WIDTH/2,GAME_SCREEN_HEIGHT/2));
	sprite->setScaleX(GAME_SCREEN_WIDTH / sprite->getContentSize().width);
	sprite->setScaleY(GAME_SCREEN_HEIGHT / sprite->getContentSize().height);

    this->addChild(sprite);

	// 添加返回主菜单按钮
	auto backItem = MenuItemImage::create(
                                           "btn_ret.png",
                                           "btn_ret.png",
										   CC_CALLBACK_1(Developer::menuBackCallback, this));
    
	backItem->setPosition(Vec2(backItem->getContentSize().width/2,GAME_SCREEN_HEIGHT-backItem->getContentSize().height/2));
    
	
    MenuItemImage *_turnOn,*_turnOff;  
    _turnOn = MenuItemImage::create(  
        "btn_musOn.png",  
        "btn_musOn.png");  
    _turnOff = MenuItemImage::create(  
        "btn_musOff.png",  
        "btn_musOff.png");  

	MenuItemImage *_trnOn,*_trnOff;
	_trnOn = MenuItemImage::create(  
        "btn_musOn.png",  
        "btn_musOn.png");  
    _trnOff = MenuItemImage::create(  
        "btn_musOff.png",  
        "btn_musOff.png");

	// 音乐开关
    MenuItemToggle *musicItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(Developer::menuMusicCallback, this), _turnOn,_turnOff, NULL);       
	musicItem->setPosition(Point(GAME_SCREEN_WIDTH/1.4,GAME_SCREEN_HEIGHT/1.8));  
	
	// 音效开关
    MenuItemToggle *soundItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(Developer::menuSoundCallback, this), _trnOn,_trnOff, NULL);       
	soundItem->setPosition(Point(GAME_SCREEN_WIDTH/1.4,GAME_SCREEN_HEIGHT/1.4));  

	auto menu = Menu::create(backItem,musicItem,soundItem, NULL);
    menu->setPosition(Vec2::ZERO);
	this -> addChild( menu );

	TTFConfig config("Marker Felt.ttf",28);
	// 关于
	auto labelAbout = Label::createWithTTF(config, "追梦赤子心");
	labelAbout -> setPosition(Point( GAME_SCREEN_WIDTH/2 , GAME_SCREEN_HEIGHT/1.2));
	labelAbout->setColor(Color3B(35,35,35));
	this->addChild(labelAbout);

	if (defaults->getBoolForKey(MUSIC_KEY)) {                                      
        musicItem->setSelectedIndex(0);                                  
    } 
	else {  
        musicItem->setSelectedIndex(1);                                  
    }

	if (defaults->getBoolForKey(SOUND_KEY)) {                                      
        soundItem->setSelectedIndex(0);                                  
    } 
	else {  
        soundItem->setSelectedIndex(1);                                  
    }
	return true;
}
开发者ID:brahmachen,项目名称:SquareHome3,代码行数:75,代码来源:Developer.cpp

示例7: init

bool GamePauseLayer::init(TopMenu* topNode){
	if(!Layer::init()){
		return false;
	}
	Size visibleSize = Director::getInstance()->getVisibleSize();

	Sprite* background = Sprite::create("bg_mainscene.jpg");
	background->setPosition(visibleSize.width/2,visibleSize.height/2);
	this->addChild(background,0);

	Sprite* prop_des = Sprite::create("props_describe.png");
	prop_des->setPosition(60,650);
	prop_des->setAnchorPoint(Point(0,0.5));
	this->addChild(prop_des,0);

	MenuItemImage* payBtn = MenuItemImage::create(
		"game_pause_buy_gold.png","game_pause_buy_gold.png",CC_CALLBACK_0(GamePauseLayer::payProps,this)
		);
	Menu* payMenu = Menu::create(payBtn, NULL);
	payMenu->alignItemsHorizontally();
	payMenu->setPosition(240,400);
	this->addChild(payMenu,0);
	MenuItemImage* exitBtn = MenuItemImage::create(
		"exit_normal.png","exit_click.png",CC_CALLBACK_0(GamePauseLayer::goBack,this)
		);

	auto scaleSmall = ScaleTo::create(0.8,0.9);
	auto scaleBig = ScaleTo::create(0.8,1);
	auto delay = DelayTime::create(0);
	auto seq2 = Sequence::create(scaleSmall,delay,scaleBig,delay->clone(),NULL);
	payBtn->runAction(RepeatForever::create(seq2));

	MenuItemImage* soundBtnOn = MenuItemImage::create("sound_effect_on.png","sound_effect_on.png");
	MenuItemImage* soundBtnOff = MenuItemImage::create("sound_effect_close.png","sound_effect_close.png");  
	MenuItemToggle* soundTog = MenuItemToggle::createWithTarget(this,menu_selector(GamePauseLayer::getSoudState),soundBtnOn,soundBtnOff,NULL);  
	if (GAMEDATA::getInstance()->getSoundEffect())  
        {  
            soundTog->setSelectedIndex(0);  
        }   
        else  
        {  
            soundTog->setSelectedIndex(1);  
        }  
	MenuItemImage* musicBtnOn = MenuItemImage::create("bg_music_open.png","bg_music_open.png");
	MenuItemImage* musicBtnOff = MenuItemImage::create("bg_music_close.png","bg_music_close.png");  
	MenuItemToggle* musicTog = MenuItemToggle::createWithTarget(this,menu_selector(GamePauseLayer::getMusicState),musicBtnOn,musicBtnOff,NULL);  
	 if (CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())  
        {  
            musicTog->setSelectedIndex(0);  
        }   
        else  
        {  
            musicTog->setSelectedIndex(1);  
        }  

	Menu* otherMenu = Menu::create(soundTog,musicTog,exitBtn, NULL);
	otherMenu->alignItemsHorizontallyWithPadding (25);
	otherMenu->setPosition(visibleSize.width/2+65,visibleSize.height/2-250);
	this->addChild(otherMenu,2);

		MenuItemImage* resumeBtn = MenuItemImage::create(
		"continue_normal.png","continue_click.png",CC_CALLBACK_0(GamePauseLayer::ResumeGame,this)
		);
	auto scale1 = ScaleTo::create(1,1.25);
	auto scale2 = ScaleTo::create(1,1);
	auto seq =Sequence::create(scale1,scale2,nullptr);
	resumeBtn->runAction(RepeatForever::create(seq));
	Menu* resumeMenu = Menu::create(resumeBtn, NULL);
	resumeMenu->alignItemsHorizontallyWithPadding (50);
	resumeMenu->setPosition(visibleSize.width/2-130,visibleSize.height/2-250);
	this->addChild(resumeMenu,2);
	return true;
}
开发者ID:joyfish,项目名称:cocos2d,代码行数:73,代码来源:GamePauseLayer.cpp

示例8: init


//.........这里部分代码省略.........
		line->setPosition(96,40);
		perNum->setPosition(105,40);
		if(per < 10){
			perTxt->setPosition(120,40);
		}else{
			perTxt->setPosition(135,40);
		}
	}else{
		line->setPosition(111,40);
		perNum->setPosition(120,40);
		if(per < 10){
			perTxt->setPosition(135,40);
		}else{
			perTxt->setPosition(150,40);
		}
	}

	auto goldBuyBtn = MenuItemImage::create(
		"gold_buy_normal.png","gold_buy_click.png",CC_CALLBACK_0(MenuLayer::pay,this)
		);
	auto goldBuyMenu = Menu::create(goldBuyBtn, NULL);
	goldBuyMenu->setPosition(53,760);
	goldBuyMenu->setAnchorPoint(Point(0,0.5));
	this->addChild(goldBuyMenu);

	gold = Gold::getInstance();
	this->addChild(gold);

	MenuItemImage* musicBtnOn = MenuItemImage::create("bg_music_open.png","bg_music_open.png");
	MenuItemImage* musicBtnOff = MenuItemImage::create("bg_music_close.png","bg_music_close.png");
	MenuItemToggle* musicTog = MenuItemToggle::createWithTarget(this,menu_selector(MenuLayer::getMusicState),musicBtnOn,musicBtnOff,NULL);
	 if (CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
		{
			musicTog->setSelectedIndex(0);
		}
		else
		{
			musicTog->setSelectedIndex(1);
		}
	auto musicMenu = Menu::create(musicTog,NULL);
	musicMenu->setPosition(349,760);
	MenuItemImage* soundEffectOn = MenuItemImage::create("sound_effect_on.png","sound_effect_on.png");
	MenuItemImage* soundEffectOff = MenuItemImage::create("sound_effect_close.png","sound_effect_close.png");
	MenuItemToggle* soundEffectTog = MenuItemToggle::createWithTarget(this,menu_selector(MenuLayer::getSoudState),soundEffectOn,soundEffectOff,NULL);
	 if (GAMEDATA::getInstance()->getSoundEffect())
		{
		    soundEffectTog->setSelectedIndex(0);
		}
		else
		{
			soundEffectTog->setSelectedIndex(1);
		}
	auto soundEffectMenu = Menu::create(soundEffectTog,NULL);
	soundEffectMenu->setPosition(427,760);
	this->addChild(musicMenu);
	this->addChild(soundEffectMenu);

	quitBg = Sprite::create("quit_bg.png");
	quitBg->setPosition(240,116);
	quitBg->setVisible(false);
	this->addChild(quitBg,10);

	quitDesc = Sprite::create("quit_desc.png");
	quitDesc->setPosition(240,144);
	quitDesc->setVisible(false);
	this->addChild(quitDesc,10);
开发者ID:joyfish,项目名称:cocos2d,代码行数:67,代码来源:MenuLayer.cpp

示例9: init

bool SignIn::init(){
	if(!Node::init()){
		return false;
	}

	auto bg = Sprite::create("bg_mainscene.jpg");
	bg->setPosition(240,400);
	this->addChild(bg);

	int level = GAMEDATA::getInstance()->getUserLevel();

	int per = (int)((float)GAMEDATA::getInstance()->getCurExpNum()/GAMEDATA::getInstance()->getFullExpNum(level)*100);

	auto levelTxt = Sprite::create("level.png");
	levelTxt->setAnchorPoint(Point(0,0.5));
	levelTxt->setPosition(30,40);
	this->addChild(levelTxt);

	auto levelNum = LabelAtlas::create(String::createWithFormat("%d",level)->_string,"level_num.png",15,22,48);
	levelNum->setAnchorPoint(Point(0,0.5));
	levelNum->setPosition(64,40);
	this->addChild(levelNum);

	auto line = Sprite::create("line.png");
	line->setAnchorPoint(Point(0,0.5));
	auto perNum = LabelAtlas::create(String::createWithFormat("%d",per)->_string,"level_num.png",15,22,48);
	perNum->setAnchorPoint(Point(0,0.5));
	auto perTxt = Sprite::create("per.png");
	perTxt->setAnchorPoint(Point(0,0.5));
	this->addChild(line);
	this->addChild(perNum);
	this->addChild(perTxt);
	if(level < 10){
		line->setPosition(81,40);
		perNum->setPosition(90,40);
		if(per < 10){
			perTxt->setPosition(105,40);
		}else{
			perTxt->setPosition(120,40);
		}
	}else if(level < 100){
		line->setPosition(96,40);
		perNum->setPosition(105,40);
		if(per < 10){
			perTxt->setPosition(120,40);
		}else{
			perTxt->setPosition(135,40);
		}
	}else{
		line->setPosition(111,40);
		perNum->setPosition(120,40);
		if(per < 10){
			perTxt->setPosition(135,40);
		}else{
			perTxt->setPosition(150,40);
		}
	}

	auto goldBuyBtn = MenuItemImage::create(
		"gold_buy_normal.png","gold_buy_click.png",CC_CALLBACK_0(SignIn::pay,this)
		);
	auto goldBuyMenu = Menu::create(goldBuyBtn, NULL);
	goldBuyMenu->setPosition(447,760);
	goldBuyMenu->setAnchorPoint(Point(1,0));
	this->addChild(goldBuyMenu);

	gold = Gold::getInstance();
	this->addChild(gold);

	MenuItemImage* musicBtnOn = MenuItemImage::create("bg_music_open.png","bg_music_open.png");
	MenuItemImage* musicBtnOff = MenuItemImage::create("bg_music_close.png","bg_music_close.png");
	MenuItemToggle* musicTog = MenuItemToggle::createWithTarget(this,menu_selector(SignIn::getMusicState),musicBtnOn,musicBtnOff,NULL);
	 if (CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
		{
			musicTog->setSelectedIndex(0);
		}
		else
		{
			musicTog->setSelectedIndex(1);
		}
	auto musicMenu = Menu::create(musicTog,NULL);
	musicMenu->setPosition(53,760);
	MenuItemImage* soundEffectOn = MenuItemImage::create("sound_effect_on.png","sound_effect_on.png");
	MenuItemImage* soundEffectOff = MenuItemImage::create("sound_effect_close.png","sound_effect_close.png");
	MenuItemToggle* soundEffectTog = MenuItemToggle::createWithTarget(this,menu_selector(SignIn::getSoudState),soundEffectOn,soundEffectOff,NULL);
	 if (GAMEDATA::getInstance()->getSoundEffect())
		{
			soundEffectTog->setSelectedIndex(0);
		}
		else
		{
			soundEffectTog->setSelectedIndex(1);
		}
	auto soundEffectMenu = Menu::create(soundEffectTog,NULL);
	soundEffectMenu->setPosition(124,760);
	this->addChild(musicMenu);
	this->addChild(soundEffectMenu);

	auto signInbg = Sprite::create("sign_in_bg.png");
	signInbg->setPosition(240,400);
//.........这里部分代码省略.........
开发者ID:joyfish,项目名称:cocos2d,代码行数:101,代码来源:SignIn.cpp


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