Add possibility to disable sound effects
This commit is contained in:
parent
9b1ff1d4ae
commit
58f6032e06
@ -38,6 +38,7 @@ class SoundManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func playSoundEffect(pathToFile: String, fileExtension: String, volumeLevel: Float){
|
func playSoundEffect(pathToFile: String, fileExtension: String, volumeLevel: Float){
|
||||||
|
self.isMusicPlaying = true
|
||||||
soundEffect = Bundle.main.url(forResource: pathToFile, withExtension: fileExtension)
|
soundEffect = Bundle.main.url(forResource: pathToFile, withExtension: fileExtension)
|
||||||
do {
|
do {
|
||||||
effectPlayer = try AVAudioPlayer(contentsOf: soundEffect!)
|
effectPlayer = try AVAudioPlayer(contentsOf: soundEffect!)
|
||||||
@ -45,7 +46,11 @@ class SoundManager {
|
|||||||
os_log("Could not load sound file %@", log: LOG, type: .error, pathToFile)
|
os_log("Could not load sound file %@", log: LOG, type: .error, pathToFile)
|
||||||
}
|
}
|
||||||
effectPlayer.volume += volumeLevel
|
effectPlayer.volume += volumeLevel
|
||||||
effectPlayer.play()
|
effectPlayer.prepareToPlay()
|
||||||
|
if self.isMusicEnabled == true {
|
||||||
|
effectPlayer.play()
|
||||||
|
UserDefaults.standard.set(false, forKey: "noMusic")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopMenuMusic() {
|
func stopMenuMusic() {
|
||||||
|
Loading…
Reference in New Issue
Block a user