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];
當我試圖讓身體與他人互動,它的行爲就好像出現了一些小的多,走形多邊形的創建來代替。
非常感謝任何見解或幫助!
對於那些想知道的人,我找到了答案。 SKPhysicsBodies必須是凸形,並且是凹形的。 – user2829127