dimanche 19 avril 2015

How to limit the number of nodes?(Spritekit)

Hey guys i have a little problem check it out:



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()
}


The problem is that when i tap for exmple 10 times on the same side of the screen (lets say the right side) it apppears 10 spritenodes and i can t use "hidden" because of the physicsBody can you guys help me?


Aucun commentaire:

Enregistrer un commentaire