user2887097
user2887097

Reputation: 309

How to set a lineWidth less than 1 for SKShapeNode?

I'm trying to make an SKShapeNode with a very think stroke (like 0.25 pixel). It seems that lineWidth of 1 is the smallest I can go, at least that's what it looks like on screen no mater what value less than 1 is set.

SKShapeNode *buttonOutline;
buttonOutline = [[SKShapeNode alloc] init];

CGMutablePathRef myPath = CGPathCreateMutable();
CGPathAddRoundedRect(myPath, NULL, CGRectMake(0, 0, 100, 30), 10, 10);    
buttonOutline.path = myPath;
buttonOutline.strokeColor=[SKColor grayColor];

buttonOutline.lineWidth= 0.25;

buttonOutline.name = [NSString stringWithFormat:@"%@-buttonOutline", thisButtonName];
buttonOutline.position =  CGPointMake(thisXPos,thisYPod);
buttonOutline.alpha = 1;

Upvotes: 11

Views: 3245

Answers (2)

Santiago Tactivos
Santiago Tactivos

Reputation: 131

Try setting the antialiased property to false. The antialias adds some extra pixels around.

// Objective-C
buttonOutline.antialiased = NO

// Swift
buttonOutline.antialiased = false

Upvotes: 13

Artur Konarski
Artur Konarski

Reputation: 41

Set scale to .25 and remember to properly upscale co-ordinates (multiply by 4 in this case)

Upvotes: 1

Related Questions