本文整理汇总了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;
}
}
}
示例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));
}
}
}
示例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);
}
示例4: toggleDetail
void MyBuildingCard::toggleDetail(cocos2d::CCNode *pSender) {
CCMenuItemToggle* toggle = ((CCMenuItemToggle*)pSender);
if(toggle->getSelectedIndex() == 1) {
displayDetail(pSender);
} else {
cancelDetail(pSender);
}
}
示例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);
}
示例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();
}
}
示例7: callbackSwitch
void ChatLayer::callbackSwitch(CCObject* pSender){
CCMenuItemToggle* pSwitch = (CCMenuItemToggle*)pSender;
if (pSwitch->getSelectedIndex()==0) {
m_blnRememberMe = false;
} else {
m_blnRememberMe = true;
}
}
示例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);
}
}
示例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());
}
示例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();
}
}
示例11: difficultyToggle
KDvoid OptionsMenu::difficultyToggle ( CCObject* pSender )
{
CCMenuItemToggle* pItem = (CCMenuItemToggle*) pSender;
m_pMessage->setString ( ccszf ( "Selected Difficulty Index:%d", pItem->getSelectedIndex ( ) ) );
}
示例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);
}