I am creating a custom edge path for a SKSpriteNode's physicsBody.
CGMutablePathRef edgePath = CGPathCreateMutable();
CGPathMoveToPoint(edgePath, NULL, -100, -70);
CGPathAddLineToPoint(edgePath, NULL, -100, 40);
CGPathAddLineToPoint(edgePath, NULL, -80, -20);
CGPathAddLineToPoint(edgePath, NULL, 30, -20);
CGPathAddLineToPoint(edgePath, NULL, 100, 100);
CGPathAddLineToPoint(edgePath, NULL, 100, -70);
CGPathCloseSubpath(edgePath);
I have tried to allocate the physicsBody using the following codes:
sprite.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromPath:edgePath];
sprite.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:edgePath];
sprite.physicsBody = [SKPhysicsBody bodyWithEdgeChainFromPath:edgePath];
None of these enable the sprite to be affected by Gravity.
However, if I use a simple bodyWithCircleOfRadius:
the sprite gets affected by gravity.
Can anybody throw some light on why this happens?