Question

I'm currently making a game and everything is going fine except for one simple thing. I'm having a problem with my app sound. When I touch the "Start" Button to play the game, it presents a new View Controller with the game itself and it plays a song. I have another view controller with its settings. Inside it, I have a UISwith that mutes the App. My problem is that when I dismiss that view controller it does not save its state. I tried NSUserDefauts and could not get it working. Maybe I'm not doing it right... If you could help me I would be very appreciated! Also, I have multiple a AVAudioPlayer (one for the game, another for when the user wins or loses) is there a way to just completely mute the entire app instead of muting every single AVAudioPlayer one at a time?

Thank you so much!

Was it helpful?

Solution

Regarding muting the sound:

- (IBAction)speakerOnOff:(id)sender
{
    static BOOL muted = NO;
    if (muted) {
        [player setVolume:1.0];
    } else {
        [player setVolume:0.0];
    }
    muted = !muted;
}

If you have multiple AVAudioPlayer just access the properties of all and setVolume:0.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top