2013-09-29 37 views
0

我无法绘制一个应该看起来像半管的多边形形状的SKPhysicsBody。我已经得到了代码如下:SpriteKit SKPhysicsBody来自CGPath多边形问题

_halfpipe_left = [SKSpriteNode spriteNodeWithImageNamed:@"halfpipe_left"]; 
    _halfpipe_left.position = CGPointMake(5*26, 5*26); 
    _halfpipe_left.anchorPoint = CGPointMake(0, 0); 

    CGMutablePathRef halfpipe_leftpath = CGPathCreateMutable(); 
    CGPathMoveToPoint(halfpipe_leftpath, NULL, 0, 0); 
    CGPathAddLineToPoint(halfpipe_leftpath, NULL, 78, 0); 
    CGPathAddLineToPoint(halfpipe_leftpath, NULL, 78, 78); 
    CGPathAddLineToPoint(halfpipe_leftpath, NULL, 52, 78); 
    CGPathAddLineToPoint(halfpipe_leftpath, NULL, 48, 59); 
    CGPathAddLineToPoint(halfpipe_leftpath, NULL, 42, 47); 
    CGPathAddLineToPoint(halfpipe_leftpath, NULL, 31, 36); 
    CGPathAddLineToPoint(halfpipe_leftpath, NULL, 19, 30); 
    CGPathAddLineToPoint(halfpipe_leftpath, NULL, 0, 26); 
    CGPathCloseSubpath(halfpipe_leftpath); 

    _halfpipe_left.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:halfpipe_leftpath]; 

当我试图让身体与他人互动,它的行为就好像出现了一些小的多,走形多边形的创建来代替。

非常感谢任何见解或帮助!

+1

对于那些想知道的人,我找到了答案。 SKPhysicsBodies必须是凸形,并且是凹形的。 – user2829127

回答