I have a moving SKSpriteNode where i detect taps on the scene with TouchesBegan based on the nodes name. This worked perfectly, until i addeed a SKEmitterNode as a child to the moving node leaving a trail of circles behind the moving node.
My touches on the main/parent node is now detected when the SKEmitterNode particle trail is being touched.
How can i only detect touches on my main/parent spritenode, but not on the child nodes of this sprite?
When the sparks that ouside node1.size is tapped, why is "node1" returned in touchesbegan and not "emitter"?
Example GameScene.swift
override func didMoveToView(view: SKView) {
let node1 = SKSpriteNode(color: SKColor.redColor(), size: CGSizeMake(400, 300))
node1.position = CGPointMake(size.width/2, size.height/2)
node1.name = "node1"
addChild(node1)
let emitter = SKEmitterNode(fileNamed: "MyParticle.sks")
emitter.name = "emitter"
emitter.zPosition = -1
node1.addChild(emitter)
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
let touch: UITouch = touches.anyObject() as UITouch
let location = touch.locationInNode(self)
let touchedNode = nodeAtPoint(location)
println(touchedNode.name)
}
userInetractionEnabled
property for each node – user4233369