2014-09-29 2 views
1

나는 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]; 

답변

3

스프라이트 키트에 오신 것을 환영합니다, 여기뿐만 아니라 그것을 배우고 및 shapeNodes을 사용한 경험이 많지 않은,하지만 것은 내가 제안 것입니다 SKShapeNode 개체의 세부 사항은 여기 찾고 제안 : Apple - SKShapeNode Reference

당신은 내가 여기에보고 제안 우수한 품질의 튜토리얼의 소스를 원하시면 : enter link description here

코드를 테스트 할 수 없으므로 코드가 작동하지 않는 경우 알려 주시면 제가 도와 드릴 수있는 방법을 알려 드리겠습니다. Sprite-Kit에 다시 오신 것을 환영합니다. 즐거운 경험이 되었길 바랍니다.

관련 문제