Hi, could anyone help to solve this: have couple of sprites with pngs, and needed to make them react only when sprite touched at its part with some data, and ignore alpha.
How to make SKSpriteNode (with png texture) be touchable only on pixels and not on alpha?
Hi,
I would try making a CGMutable path that has the best estimation of the border of the image and using the CGPath's .containsPoint()
method to test if the location the user tapped is contained in the point. I know that you can create an SKPhysicsBody from a texture that uses a specific alpha threshold, but I couldn't find a way to get a path from that or test to see if a point is contained in the physics body.
Here are some links that might help:
https://developer.apple.com/documentation/spritekit/skphysicsbody/shaping_a_physics_body_to_match_a_node_s_graphics
https://developer.apple.com/documentation/coregraphics/cgmutablepath
Good luck!