楕円形を作成しようとしています。私は使用bodyWithEdgeLoopFromPath
して動作しましたが、他のオブジェクトが途中で引っかかることがあるため、何か問題があるようです。
しかし、楕円をしっかりしたいので、試してみbodyWithPolygonFromPath
ました(静的にしたい)
horizontalOval = [[SKShapeNode alloc] init];
theRect = CGRectMake(0, 0, self.frame.size.width/6 , 15);
CGMutablePathRef ovalPath = CGPathCreateMutable();
CGPathAddEllipseInRect(ovalPath, NULL, theRect);
horizontalOval.path = ovalPath;
horizontalOval.fillColor = [UIColor blueColor];
horizontalOval.physicsBody.dynamic = NO;
horizontalOval.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:ovalPath];
しかし、エラーが発生しました
SKPhysicsBody: Error attempting to create polygon with 17 vertices, maximum is 12
複雑なパスを作成してソリッドにする方法は?
また、位置を合わせてプディングすると、self.frame.size.width/2
中央self.frame.size.height/2
に留まらず、少し右にずれます。
中央にしなければならなかったのtheRect = CGRectMake(-40, 0........)
ですが、なぜですか?
UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: _paddleRect];
ただし、頂点は 13 個です。使用しようとしていますPaintCode
。