Add --no-music flag, Implement NSUserDefaults for music settings

This commit is contained in:
Simon Kellner 2020-06-08 10:40:53 +02:00
parent 46fa90bfe3
commit 2f32943511
2 changed files with 3 additions and 1 deletions

View File

@ -56,7 +56,7 @@ class MenuScene: SKScene {
entityManager.add(Background(size: self.size))
entityManager.add(SpinningLogoEntity(position: CGPoint(x: midX, y: midY + 200)))
if SoundManager.sharedInstance.isMusicPlaying == false && SoundManager.sharedInstance.isMusicEnabled == true {
if SoundManager.sharedInstance.isMusicPlaying == false && SoundManager.sharedInstance.isMusicEnabled == true && !CommandLine.arguments.contains("--no-music") && !UserDefaults.standard.bool(forKey: "noMusic"){
SoundManager.sharedInstance.startMenuMusic()
}
}

View File

@ -29,12 +29,14 @@ class SoundManager {
audioPlayer.prepareToPlay()
if self.isMusicEnabled == true {
audioPlayer.play()
UserDefaults.standard.set(false, forKey: "noMusic")
}
}
func stopMenuMusic() {
audioPlayer.pause()
self.isMusicPlaying = false
UserDefaults.standard.set(true, forKey: "noMusic")
}
func setVolume(_ volume: Float) {