SKSpriteNode Touch on non transparent area

Hi,

I have a problem that don’t found solution, I search and read a lot of post but nothing work.
I have some SKSpriteNode with transparent area and I need detect the touch only on the non transparent area.

With…

if let touchedBody:SKPhysicsBody = self.physicsWorld.body(at: pos) {   
            if let theSprite:SKSpriteNode = touchedBody.node as? SKSpriteNode {
                print(theSprite)
            }
        }

Only work the last one SKSpriteNode and only at some locations inside the non transparent sprite.

With…

for node in nodes(at: pos) {
            if (node.name != "gameboard"){    
                print("Node position \(node.position) name \(node.name)") 
            } 
}

I get all the nodes at location, but only is valid the non transparent.
I try to get the alpha value of the texture but I’m blocked… :frowning:

Any other way to solve this? What I’m doing wrong?

This topic was automatically closed after 166 days. New replies are no longer allowed.