문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top