i create a SKSpriteNode with an Emitter as Child
onObject: SKSpriteNode! = SPSpriteNode(texture: ballTexture)
onObject.physicsBody = SKPhysicsBody(circleOfRadius: (ballSize / 2) * 0.99)
onObject.physicsBody?.affectedByGravity = true
onObject.physicsBody?.allowsRotation = true
onObject.physicsBody?.isDynamic = true
onObject.physicsBody?.mass = 3
onObject.physicsBody?.angularDamping = 1
onObject.physicsBody?.angularVelocity = ballRotation
onObject.physicsBody?.applyAngularImpulse(ballRotation)
onObject.physicsBody?.restitution = 0.5
let particles = SKEmitterNode(fileNamed: "emitter.sks")
particles?.zPosition = onObject.zPosition - 1
particles?.particleZPosition = onObject.zPosition - 1
particles?.position = CGPoint(x: 0, y: 0)
particles?.targetNode = self
particles?.particlePositionRange.dx = onObject.size.width
particles?.particlePositionRange.dy = onObject.size.height
particles?.name = "particles"
particles?.isUserInteractionEnabled = false
onObject.addChild(particles!)
but if i touch the emitter, the action will be triggered even if the userinteraction is disabled?!
how could i fix it?
i already tried to ignore the touched.name (particles) but it doesn't seem to work because every time i touch the particles or anywhere near it, the parent node will also get the touch event.
how could i prevent this?
im checking the Touch Event in
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let touch = touches.first!
let positionInScene = touch.location(in: self)
let touchedNodes = self.nodes(at: positionInScene)
print(touchedNode.name)
if ((touchedNode.name?.range(of: powerUps.POWERUPS)) != nil){
print("powerUp Touched")
}
}