【发布时间】:2015-03-23 17:15:43
【问题描述】:
我正在为 iOS 开发一款小游戏。
我的场景中有一个 SKSpriteNode - 当我使用“removeFromParent”删除它并触摸它最后进入的区域时,我仍然可以使用该功能。
我的代码如下:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
if tapToPlayNode.containsPoint(location){
tapToPlayNode.removeFromParent()
startNewGame()
}
}
}
func startNewGame(){
//Starts a new game with resetted values and characters in position
println("Ready.. set.. GO!")
//Shows the ui (value 1)
toggleUiWithValue(1)
}
换句话说,我得到“Ready.. set.. GO!”即使在删除区域后,当我触摸该区域时也会输出。
有什么线索吗?
最佳,
【问题讨论】:
标签: ios swift sprite-kit skspritenode