【发布时间】:2015-12-23 18:08:03
【问题描述】:
我无法检测到被触摸的特定节点。这是我必须要做的。
let playagain = SKSpriteNode(imageNamed: "PlayAgain.png")
override func didMoveToView(view: SKView) {
super.didMoveToView(view)
}
然后当玩家死亡时,这两个节点就会出现。
playagain.position = CGPoint(x:frame.size.width * 0.5, y: frame.size.height * 0.5)
addChild(playagain)
gameover.position = CGPoint(x:frame.size.width * 0.5, y: frame.size.height * 0.75)
addChild(gameover)
上面的一切都有效。该节点出现在我问我的屏幕上,我似乎无法让它显示我点击了它。 如您所见,该节点称为 playagain,当单击 playagain 节点时,我希望能够刷新游戏。到目前为止我所拥有的如下。
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
for touch in touches {
let location = (touch as! UITouch).locationInNode(self)
let play = self.nodeAtPoint(location)
if play.name == "playagain" {
println("touched")
}
}
}
谢谢!
【问题讨论】:
标签: xcode swift touch nodes skspritenode