我正在尝试找出如何使用 SKScene 的子类检测屏幕上任何位置的触摸,以便我可以进行转换。我该怎么做?
谢谢
最佳答案
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let location = touch.location(in: self)
print(location)
//if your touch location = a button or anything it transitions to a new scene
if location = //Startbutton {
let transition = SKTransition.reveal(with: .down, duration: 0.75)
let gameScene = GameScene(size: size)
gameScene.scaleMode = scaleMode
view?.presentScene(gameScene, transition: transition)
打印用户触摸位置...希望对 m8 有帮助
关于ios - 使用 Swift/SKScene 检测触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44399813/