我只是想知道如何从场景中移除SKSprite节点。这是我到目前为止有:Swift + Sprite套件触摸检测
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = (touch as UITouch).locationInNode(self)
if let theName = self.nodeAtPoint(location).name {
if theName == "monster" {
monster! .removeFromParent()
}
}
}
}
我创造很多在屏幕上这些怪物的,但是当我在其中一人挖掘它不会做任何事情。如果我尝试添加println("touched")
,它告诉我它已被触动。
您是否给每个怪物命名为“怪物”?你有没有在所有的怪物上设置userInteractionEnabled为true? – Okapi