Skip to content

Commit

Permalink
Add main music
Browse files Browse the repository at this point in the history
  • Loading branch information
sp4ce-cowboy committed Apr 3, 2024
1 parent 687fd8e commit 9d5a59f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions TowerForge/TowerForge/Commons/Sounds/AudioManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ internal class AudioManager: NSObject, AVAudioPlayerDelegate {

/// Plays background music
func playMainMusic() {
stopBackground()
if !isMainPlaying {
mainAudioPlayer?.play()
isMainPlaying = true
Expand All @@ -102,6 +103,7 @@ internal class AudioManager: NSObject, AVAudioPlayerDelegate {

/// Plays background music
func playBackground() {
stopMainMusic()
if !isBackgroundPlaying {
backgroundAudioPlayer?.play()
isBackgroundPlaying = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import UIKit
class MainMenuViewController: UIViewController {
var selectedGameMode: Mode = .deathMatch

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
AudioManager.shared.playMainMusic()
}

@IBAction private func DeathMatch(_ sender: Any) {
selectedGameMode = .deathMatch
performSegue(withIdentifier: "segueToGame", sender: self)
Expand Down

0 comments on commit 9d5a59f

Please sign in to comment.