diff --git a/GoldWars/GoldWars/Scenes/MenuScene.swift b/GoldWars/GoldWars/Scenes/MenuScene.swift index c1b93de..a65bda9 100644 --- a/GoldWars/GoldWars/Scenes/MenuScene.swift +++ b/GoldWars/GoldWars/Scenes/MenuScene.swift @@ -25,6 +25,7 @@ class MenuScene: SKScene { onButtonPress: { if CommandLine.arguments.contains("--no-matchmaking") { self.loadScene(scene: GameScene(size: self.size)) + self.soundManager.stopMenuMusic() } else { MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self) } @@ -34,12 +35,11 @@ class MenuScene: SKScene { text: "Settings", position: CGPoint(x: midX, y: midY - 80 ), onButtonPress: { - //TODO: create Settings Scene self.loadScene(scene: SettingsScene(size: self.size)) })) entityManager.add(Background(size: self.size)) - if soundManager.isMusicPlaying == false { + if SoundManager.isMusicPlaying == false { soundManager.startMenuMusic() } } diff --git a/GoldWars/GoldWars/SettingsScene.swift b/GoldWars/GoldWars/SettingsScene.swift index 99f741b..96aec88 100644 --- a/GoldWars/GoldWars/SettingsScene.swift +++ b/GoldWars/GoldWars/SettingsScene.swift @@ -9,7 +9,6 @@ import SpriteKit class SettingsScene: SKScene { - var entityManager: EntityManager! override func sceneDidLoad() { diff --git a/GoldWars/GoldWars/SoundManager.swift b/GoldWars/GoldWars/SoundManager.swift index 808c321..ec09e1c 100644 --- a/GoldWars/GoldWars/SoundManager.swift +++ b/GoldWars/GoldWars/SoundManager.swift @@ -12,9 +12,10 @@ import AVFoundation class SoundManager { var audioPlayer = AVAudioPlayer() var backgroundMainMenuAudio: URL? - var isMusicPlaying: Bool = false + static var isMusicPlaying: Bool = false func startMenuMusic() { + SoundManager.isMusicPlaying = true backgroundMainMenuAudio = Bundle.main.url(forResource: "intro-music", withExtension: "mp3") do { audioPlayer = try AVAudioPlayer(contentsOf: backgroundMainMenuAudio!) @@ -24,11 +25,10 @@ class SoundManager { audioPlayer.numberOfLoops = -1 audioPlayer.prepareToPlay() audioPlayer.play() - isMusicPlaying = true } func stopMenuMusic() { audioPlayer.pause() - isMusicPlaying = false + SoundManager.isMusicPlaying = false } }