SKPhysicsBody Path Generator

Want to use [SKPhysicsBody bodyWithPolygonFromPath:path] easier way like me? Here with a small helper for easier path drawing, hope it help others too.

Basic Instruction
  1. Drag and drop the sprite image into drop zone.
  2. Start drawing path by clicking on coordinates.
Some Rules / Known Issue
  • Path need to be as a convex polygonal path with counterclockwise winding and no self intersections. The points are specified relative to the owning node’s origin. (documentation link)
  • Please use Chrome for best compatibility as I have not tested on other browsers.

Retina? (please check before declaring path)

X:0 Y:0


Output
SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"img"];

CGFloat offsetX = sprite.frame.size.width * sprite.anchorPoint.x;
CGFloat offsetY = sprite.frame.size.height * sprite.anchorPoint.y;

CGMutablePathRef path = CGPathCreateMutable();


CGPathCloseSubpath(path);

sprite.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path];