I am making a game using SpriteKit and Swift, running Xcode 6. I have an SKLabelNode
, let\'s call it myLabelNode
for this example. When I call my
Your labelNode
may not be inside the SKScene
anymore. This does not mean that it will not respond to the containsPoint
function. The labelNode
still has a position assigned to it and it can calculate if a point falls inside it using containsPoint
function.
Instead you can try this.
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
let touch = touches.anyObject() as UITouch
let location = touch.locationInNode(self)
if self.nodeAtPoint(location) === lemonadeLabel {
println("lemonadeLabel pressed")
lemonadeLabel.removeFromParent()
}
}