如何限制节点数? (Spritekit)

时间:2015-04-20 06:34:07

标签: ios swift sprite-kit

我有点问题。看看:

 override func touchesBegan(touches: Set, withEvent event: UIEvent) {

for touch in (touches as! Set<UITouch>) {

var Location:CGPoint = touch.locationInNode(self)
var Node:SKNode = self.nodeAtPoint(Location)

 if(Location.x < self.size.width/2) {

        node2.addchild(sprite2)
        node1.removeFromParent()
}
if (Location.x > self.size.width/2) {

        node1.addchild(sprite1)

        node2.removeFromParent()
}

问题在于,当我在屏幕的同一侧(例如,右侧)点击10次时,它会施加10个spritenodes,因为物理体,我不能使用“隐藏”。你能帮助我吗?

0 个答案:

没有答案