나는 SpriteKit을 배우기 시작했고 곧바로 문제가 생겼다. SKShapeNode 빈 사각형을 그리려면 노력하고 있지만 화면에 나타납니다. 채우기 속성에 색상을 설정하면 사각형이 나타납니다. 내가 도대체 뭘 잘못하고있는 겁니까 ?SKShapeNode 빈 사각형
//If you want the shape to be that of a rectangle I would suggest using a simpler allocation method such as the following:
SKShapeNode *shapeNode = [SKShapeNode shapeNodeWithRectOfSize:CGSizeMake(self.frame.size.width/2, self.frame.size.height/2))];
/*shapeNodeWithRectOfSize is a built in allocation method for SKShapeNodes that handles
allocation and initialization for you, and will also create the rectangle shape for you.
The CGSizeMake method will return a CGSizeMake object for you*/
/*a CGSizeMake object is an object with two properties: width, and height. It is used to hold
the dimensions of objects. self.frame.size is a CGSize object*/
/*You do not need to set the fill color to nil. This is because the default is [SKColor clearColor]
which is an empty color already*/
//Make sure that you use an initializer method when setting the colour as below
shapeNode.strokeColor = [SKColor redColor];
shapeNode.lineWidth = 3;
[self addChild:shapeNode];
당신에 대한 참조를 원하는 경우
CGRect box = CGRectMake(0, 0, self.frame.size.width/2, self.frame.size.height/2);
SKShapeNode *shapeNode = [[SKShapeNode alloc] init];
shapeNode.path = [UIBezierPath bezierPathWithRect:box].CGPath;
shapeNode.fillColor = nil;
shapeNode.strokeColor = SKColor.redColor;
shapeNode.lineWidth = 3;
[self addChild:shapeNode];