I want to learning make a sample game on Apple Watch which install watchOS 8.
I use SwiftUI to wrap the SpriteView for displaying the game scene. All work fine except handling the touch event. When I override the function " touchesEnded " in GameScene, it report error for no such function on watchOS.
How to handle the tap event on watchOS ? Any suggestion is welcome, thank you.
struct ContentView: View {
var sz = WKInterfaceDevice.current().screenBounds.size
var scene: SKScene {
let scene = GameScene()
scene.size = sz
scene.scaleMode = .resizeFill
return scene
}
var body: some View {
SpriteView(scene: scene)
.frame(width: sz.width, height: sz.height)
.ignoresSafeArea()
}
}
class GameScene: SKScene {
override func sceneDidLoad() {
print("sceneDidLoad size=\(size.width),\(size.height)")
myInit()
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
// build error for no touchesEnded func on watchOS
}
}