CCMenuToggle and SimpleAudioEngine missing functions?

Hi,

I am going to porting my game from cocos2d/ios to cocos2d-x/android.

But I can’t find the corresponding methods about CCMenuToggle and SimpleAudioEngine.

Here are part of my codes, can someone give me a light ?

Thank you.

musicButton is a CCMenuItemToggle

musicButton.selectedIndex = 0;
[[SimpleAudioEngine sharedEngine] setMute:NO];

AFAIK, there’s no CCMenuToggle since cocos2d-iphone 0.99.4. I haven’t ported this class to cocos2d-x. Also there’s no setMute(bool) interface in SimpleAudioEngine.
About SimpleAudioEngine, a namespace is required CocosDenshion::SimpleAugioEngine::sharedEngine()->setEffectsVolume(0)

Sorry, it’s my typo error.

The correct class name is CCMenuItemToggle, and I do get it compile fine on cocos2d-x.

I need this to switch the music on/off icon image.

As for the mute, if there is no setMute(bool), I will try the setEffectsVolume(0).

Thank you for your great work for cocos2d-x.

Hi,

I found a solution for the mute and CCMenuItemToggle questions.

You can just use setEffectVolume(0) and setBackgroundMusicVolume(0) as Walzer Wang mentioned.

When you want to let the sound back, just use setEffectVolume(1) and setBackgroundMusicVolume(1).

As for CCMenuItemToggle question, you can use the setSelectedIndex(I didn’t see this method on Doxygen, but you can trace the code , and you will find it) to make CCMenuItemToggle to show which image for you.

For example, if user choose sound off when he leave the game last time, and when he comes back, the sound control need to use the sound off image and make sound/music off.

Something like musicButton->setSelectedIndex(1).

Hope it will help other newbies like me.