I'm trying to create a SKPhysicsBody from a texture containing alpha values dynamically. Unfortunately the SKPhysicsBody is created from just one piece in the texture. How can I solve that?
Here's how the SKPhysicsBody is being created:
physicsBody = SKPhysicsBody(texture: texture!, size: size)
Edit:
For the sake of completeness, I found a way to solve that problem now.
Sadly I can't just create the SKPhysicsBody with this convenient function from the texture. Once the texture would contain more than one shape it'll no longer work.
Basically what I do is to create the initial path manually, do all calculation on the paths itself and store them all, then re-create the SKPhysicsBodies from this paths after each change.
I use an open source clipping library (Clipper) which I pass the paths to clip and which gives me back a two dimensional CGPoint array containing all paths/polygons from all shapes. I use this paths to create the new SKPhysicsBodies and merge them with SKPhysicsBody(bodies: [SKPhysicsBody]).