1
我在檢測正在觸摸的特定節點時遇到問題。這是我所需要的。SKSpriteNode touch detected swift
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")
}
}
}
謝謝!
啊! –
您能否請您將問題標記爲已回答。謝謝 – crashoverride777