1
votes

In the below the yellow circle does not show in the IOS emulator. If I add the setFillColor which is currently commented out, then I get a red circle.

Why does the outline of the shape not show? Is there a way to trigger the outline?

-(void)addTargetNode2 {
    float radius=90;
    SKShapeNode *targetOuter = [SKShapeNode shapeNodeWithCircleOfRadius:radius];
    //[targetOuter setFillColor:[UIColor redColor]];
    [targetOuter setStrokeColor:[UIColor yellowColor]];
    [targetOuter setLineWidth:1];

    //Position the node.
    targetOuter.position = CGPointMake(CGRectGetMidX(self.frame),
                                      CGRectGetMidY(self.frame));

    [self addChild:targetOuter];
}

I did find this article - but no answer.

Edit: I've got a working work-around... but not particularly fond of it. Drawing a circle the color of the background over the top of a filled in circle:

-(void)addTarget {
    float radius=50;
    CGFloat borderWidth=3;

    //Draw the Circle.
    SKShapeNode *targetOuter = [SKShapeNode shapeNodeWithCircleOfRadius:radius];
    [targetOuter setName:@"targetOuter"];
    [targetOuter setFillColor:[UIColor yellowColor]];
    //Following line should set the outline color but isn't working.
    //[targetOuter setStrokeColor:[UIColor yellowColor]];
    [targetOuter setLineWidth:1];
    targetOuter.position = CGPointMake(CGRectGetMidX(self.frame),
                                      CGRectGetMidY(self.frame));        
    [self addChild:targetOuter];

    /* Work around
     Add a circle the color of the background to emulate an outline.
     Can be removed in targetOuter outline works.
    */
    SKShapeNode *targetInner = [SKShapeNode shapeNodeWithCircleOfRadius:radius-borderWidth];
    [targetInner setFillColor:self.backgroundColor];
    targetInner.position = targetOuter.position;
    [self addChild:targetInner];
}
1

1 Answers

1
votes

It seems there is a bug with the iOS simulator and SKShapeNode. I've been able to replicate this problem on simulator but never on device so you shouldn't worry to add a workaround.

iOS Simulator is good to test low framerate conditions and different screen sizes but, aside from that, not very reliable to test SpriteKit games overall.