我最近使用XCode7和Swift 2.0将我的SpriteKit游戏更新到了iOS9,并在新的iPhone 6s上运行。使用下面的代码。问题是第一次触摸已注册,但未识别后续触摸。
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in (touches ) {
print(touch)
let touchLocation = touch.locationInNode(self)
//Other code
}
}
我第一次运行SKScene时也遇到错误<CAMetalLayer: 0x12ed24bb0>: calling -display has no effect.
。不确定这与我的问题有关。
如何获得多次触摸的任何想法?我稍后将使用我的旧iPhone 5S进行测试,看看iPhone 6S或iOS9 / XC7 / Swift2.0是否存在问题。
答案 0 :(得分:0)
该修复正在向self.view?.multipleTouchEnabled = true
didMoveToView(view: SKView)
希望这可以挽救其他人造成的痛苦!
答案 1 :(得分:0)
针对 iPhone 6s 和 iPhone 6s plus
的UITouch类方法进行了一些修改因此您需要为您覆盖的每个触摸方法调用基类方法,如:
实施例 -
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
// Other Code
}