diff --git a/GoldWars/GoldWars/RoundTimer.swift b/GoldWars/GoldWars/RoundTimer.swift index 4d4a699..f7913bf 100644 --- a/GoldWars/GoldWars/RoundTimer.swift +++ b/GoldWars/GoldWars/RoundTimer.swift @@ -30,7 +30,9 @@ class RoundTimer: Timer { } func stopTimer() { + guard timer != nil else { return } timer?.invalidate() + timer = nil } func resumeTimer() { diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index b23726b..f6fe24a 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -243,6 +243,8 @@ class GameScene: SKScene{ } @objc func pauseGame() -> Void { + entityManager.removeModal() + entityManager.getHUD()?.roundTimer.stopTimer() entityManager.add(Modal(modaltype: .PauseGame, base: nil, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), @@ -251,7 +253,6 @@ class GameScene: SKScene{ touchLocation: nil, collisionBase: nil )) - entityManager.getHUD()?.roundTimer.stopTimer() } @objc func resumeGame() -> Void { entityManager.removeModal()