我在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))
}
}
}
出于某种奇怪的原因,当我触摸屏幕时,第6行上的打印不会打印出来,因此意味着没有检测到触摸。任何想法或修复,是否有其他人有这个问题?提前谢谢。