Gibt es eine Möglichkeit, die SKPhysicsbody-Grenze von Sprite Kits visuell zu erkennen?

Ich benutze bodyWithPolygonFromPath, um das Volumen des Physikkörpers zu definieren, und verwendet

http://dazchong.com/spritekit/

die erforderlichen Pfade zu bekommen. Aber der Pfad scheint nicht korrekt zu sein und ich möchte die Grenzlinie des Physikpfad sehen, um zu sehen, ob die Form korrekt ist.

Gibt es eine Möglichkeit, den Volumenumriss des Physikers zu sehen?

Ich habe den folgenden Code ausprobiert, aber er funktioniert nicht.

ship = [SKSpriteNode spriteNodeWithImageNamed: @ "Spaceship"];

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

CGMutablePathRef path = CGPathCreateMutable();

CGPathMoveToPoint(path, NULL, 50 - offsetX, 110 - offsetY);
CGPathAddLineToPoint(path, NULL, 18 - offsetX, 16 - offsetY);
CGPathAddLineToPoint(path, NULL, 140 - offsetX, 15 - offsetY);

CGPathCloseSubpath(path);

SKShapeNode *yourline = [SKShapeNode node];
yourline.name = @"yourline";
yourline.path = path;
[yourline setStrokeColor:[UIColor redColor]];
 [self addChild:yourline];


ship.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path];
//[ship setScale:0.5];
ship.zRotation = - M_PI / 2;

Antworten auf die Frage(7)

Ihre Antwort auf die Frage