gra*_*234 6 xcode cocoa-touch touch touchesbegan swift3
我在Xcode 8.0 beta上用swift 3.0制作游戏.在我的GameScene中我有这个touchBegan
功能:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for t in touches {
let location = t.location(in: self)
let nodeAtTouch = self.atPoint(location)
let touchedSprite = nodeAtTouch as! SKSpriteNode
print("Touch Detected")
if touchedSprite is SKButton {
print("Button Touched")
touchedSprite.run(SKAction.resize(byWidth: 25, height: 25, duration: 0.25))
}
}
}
Run Code Online (Sandbox Code Playgroud)
由于某些奇怪的原因,当我触摸屏幕时,第6行上的打印不会打印出来,因此意味着没有检测到触摸.任何想法或修复,是否有其他人有这个问题?提前致谢.