Hello, I realize that this question is old but thought I would respond. Their is MenuItemToggle class that will exercise the toggle button functionality. The toggle can toggle any number items, for example difficulty easy, medium, and hard. The code below creates a toggle menu that may satisfy your need. This is an example for toggle background music. It can be adapted of course. I hope this may help some one.
auto pSoundText = MenuItemFont::create(“Music”);
auto itemOn = MenuItemImage::create("sound.png", "sound.png", [&](Ref* sender){
SimpleAudioEngine::getInstance()->playBackgroundMusic(GameAssets::Sound::GAME_BACKGROUND_SOUND, true);
PersistenceManager::getInstance()->setProperty(UserData::KEY_ISPLAYBGMUSIC,true );
});
auto itemOff = MenuItemImage::create("mute.png", "mute.png", [&](Ref* sender){
SimpleAudioEngine::getInstance()->stopBackgroundMusic();
PersistenceManager::getInstance()->setProperty(UserData::KEY_ISPLAYBGMUSIC,false );
});
itemToggleMusic = MenuItemToggle::createWithCallback([&](Ref* pSender){
MenuItemToggle *toggleItem = (MenuItemToggle *)pSender;
if (toggleItem->getSelectedItem() == itemOn) {
SimpleAudioEngine::getInstance()->playBackgroundMusic(GameAssets::Sound::GAME_BACKGROUND_SOUND, true);
PersistenceManager::getInstance()->setProperty(UserData::KEY_ISPLAYBGMUSIC,true );
} else if (toggleItem->getSelectedItem() == itemOff) {
SimpleAudioEngine::getInstance()->stopBackgroundMusic();
PersistenceManager::getInstance()->setProperty(UserData::KEY_ISPLAYBGMUSIC,false );
}
}, itemOn,itemOff, NULL);
Menu* pMenu= Menu::create(pSoundText,itemToggleMusic, NULL);
pMenu->alignItemsVerticallyWithPadding(32);
pMenu->setPosition( Vec2(Utils::getMidPoint().x, Utils::getWindowSize().height - 400) );
pMenu->setAnchorPoint( Vec2 (0 , 0.5));
addChild(pMenu, 1);