So, basically, I have a sprite (.png) in SpriteKit
, where most of the pixels are zero/no detail etc.
I wish to create a UIBezierPath
of only the detail inside the Sprite, so later I can use containsPoint
.
After a bunch of googling I found you can create a PhysicsBody
using the path of the Texture in the sprite image, like this:
let texture = SKTexture(imageNamed: "myImage.png")
img.physicsBody = SKPhysicsBody(texture: texture, size: img.size)
This creates a physics body around only the detail inside the image, excluding any alpha value pixels, if you know what I mean.
Is there a way to create a BezierPath
doing the same? or maybe creating a CGPath
, then using that to create a BezierPath
?
The reason is, I'm hoping to test if a CGPoint
is inside this sprite, without using the physicsDelegate
or physicsBodys
.
Thanks in advance.