1

I have 8 levels in my Game application. Each level screen has sound control button on top-right corner. When I click on that button it Toggles sound on/off.

If it is turned off in level one, it should be off in all levels. How can I do that?

Guru
  • 21,652
  • 10
  • 63
  • 102
maniclorn
  • 1,081
  • 3
  • 12
  • 23

1 Answers1

0

If you use CocosDenshion to play your music, you can simply call

[[SimpleAudioEngine sharedEngine] setBackgroundMusicVolume: value];
[[SimpleAudioEngine sharedEngine] setEffectsVolume: value];

value is float in range of 0..1

Morion
  • 10,495
  • 1
  • 24
  • 33
  • I found a solution. Using a global variable in AppDelegate. Now anytime I can set it's value to YES or NO and call these methods. – maniclorn Jul 04 '12 at 12:24
  • is there a way to disable them separately? – OMGPOP Mar 09 '13 at 01:07
  • what do you mean under "separately"? i post two lines of code as example. one disables background music, the second for effects. if you wanna change volume for a single effect, take a look to the CDSoundSource class of CocosDenshion. – Morion Mar 10 '13 at 00:34
  • Cannot understand what do you mean. I gave an answer for maniclorn question. He accepted it, so we can see that this way was good for him. If you want to know something else, create another thread or try to find existing one. At least take a look to the class i mentioned in comments to your message. – Morion Mar 19 '13 at 11:43