I'm using Xcode, SKSpriteKit and am creating a game.
I need my program to draw a quadrilateral in a function.
-(void) DrawQuad {
//Draw Quadrilateral here with points (a,b), (c,d), (e,f), (g,h)
}
I have already tried other links/help but for some reason, the code I paste doesn't work.
For example, at: Draw Rectangle/ Circle and Triangle in Spritekit with Two Colors. . ., I try copy and pasting that function into my code (In the .mm file). It doesn't work:
Even making the suggested changes in the program still doesn't resolve the issue.
SKShapeNode draws a shape defined by a Core Graphics path. If I remember correctly, UIBezierPath is not part of that but you can use CGPath instead.
Look at this sample code:
SKShapeNode *myNode = [[SKShapeNode alloc] init];
myNode.position = CGPointMake(300,300);
myNode.zPosition = 100;
CGMutablePathRef myPath = CGPathCreateMutable();
CGPathMoveToPoint(myPath, nil, 0, 0);
CGPathAddLineToPoint(myPath, nil, 0, 100);
CGPathAddLineToPoint(myPath, nil, 100, 100);
CGPathAddLineToPoint(myPath, nil, 100, 0);
CGPathAddLineToPoint(myPath, nil, 0, 0);
myNode.path = myPath;
CGPathRelease(myPath);
myNode.strokeColor = [SKColor redColor];
[self addChild:myNode];