My final game over scene has an SKTransition back to the Main Menu. I am able to make a song play for the final game over scene, but I would like the song to continue into my Main Menu.
Here is a copy of the code I have at the moment.
import Foundation
import SpriteKit
import AVFoundation
class SceneThree: SKScene {
var game = SKSpriteNode()
var new: AVAudioPlayer?
override func didMove(to view: SKView) {
self.backgroundColor = SKColor.black
playSound()
}
func playSound() {
let url = Bundle.main.url(forResource: "new", withExtension: "caf")!
do {
new = try AVAudioPlayer(contentsOf: url)
guard let new = new else { return }
new.prepareToPlay()
new.play()
} catch let error {
print(error.localizedDescription)
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let gameScene = GameScene(fileNamed: "GameScene")
gameScene?.scaleMode = .aspectFill
self.view?.presentScene(gameScene!, transition: SKTransition.fade(withDuration: 4.5))
}