Search code examples
swiftsprite-kitskphysicsbodyskcropnode

Masking and Physics in SpriteKit


When using SKCropNode in SpriteKit, does the masking affect the physics of the node? (e.g. I crop half of the sprite, will a ball fall through the masked part of the image?) If this is the case, how would I go about creating the SKCropNode so it would crop where ever I touch?

Cheers


Solution

  • SKCropNode only pertains to how a node appears on the screen, it does not deal with physics bodies. You can however use SKPhysicsBody(polygonFrom:CGPath) to create a path that is identical to the body you are trying to mimic, with the gap and everything. I recommend using the program PhysicsEditor to achieve such effect. https://www.codeandweb.com/physicseditor