So basically, I have sprite (.png) in SpriteKit, where most of the pixels are zero / no details, etc.
I want to create UIBezierPathonly the details inside the sprite, so later I can use containsPoint.
After a bunch of search query, I found that you can create PhysicsBodyusing the texture path in the sprite image, for example:
let texture = SKTexture(imageNamed: "myImage.png")
img.physicsBody = SKPhysicsBody(texture: texture, size: img.size)
This creates a physical body around only the detail inside the image, excluding any pixels of alpha values, if you know what I mean.
Is there any way to create BezierPathto do the same? or perhaps create CGPathand then use this to create BezierPath?
The reason is because I hope to check if there is any CGPointinside this sprite, without using physicsDelegateor physicsBodys.
Thanks in advance.
source
share