I have a game with SpriteKit for iPhone, iPad and Mac. I am gonna make for Apple TV. But I take it override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
doesn't work for tvOS. Then what I am supposed to use to make my buttons selectable and I can press ones?
touchesBegan for tvOS in the game?
touchesBegan:withEvent: is available on tvOS 9.0+
That's how I am pushing buttons in my game.
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first {
let position = touch.location(in: self)
let node = self.atPoint(position)
switch node {
case meow1off:
if let musicURL = Bundle.main.url(forResource: self.meows[0], withExtension: "mp3") {
self.meow1Sound = SKAudioNode(url: musicURL)
self.addChild(self.meow1Sound)
}
case meow2off:
if let musicURL = Bundle.main.url(forResource: self.meows[1], withExtension: "mp3") {
self.meow2Sound = SKAudioNode(url: musicURL)
self.addChild(self.meow2Sound)
}
...
}
}