I seem to be having problems with one of the Nodes on my scene.
I have a button:
func createAttackButton() {
attackButton.zPosition = 1
attackButton.anchorPoint = CGPointZero
attackButton.position = CGPointMake(20, 20)
attackButton.size = CGSize(width: 150, height: 40)
addChild(attackButton)
}
This function is called when contact is made with the enemy.
To run a function from this button I use the touchesBegan() func:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
if attackButton.containsPoint(location) {
print("Attack Button Clicked")
}
}
}
Once the enemy has been destroyed I remove the Attack Button Node:
attackButton.removeFromParent()
However, in the area where the attack button appears, once it has been removed, that area is still clickable.
Any ideas?