I copied the code below from a tutorial. However, an error about addChild pops up. It says, "Cannot convert value of type 'SKAudioNode' to expected argument type 'UIViewController'". How can I fix this?
import AVFoundation
import SpriteKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func didMove(to view: SKView) {
let music = SKAudioNode(fileNamed: "3D_Beep.mp3")
addChild(music)
music.isPositional = true
music.position = CGPoint(x: -1024, y: 0)
let moveForward = SKAction.moveTo(x: 1024, duration: 2)
let moveBack = SKAction.moveTo(x: -1024, duration: 2)
let sequence = SKAction.sequence([moveForward, moveBack])
let repeatForever = SKAction.repeatForever(sequence)
music.run(repeatForever)
}
}