Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
like image 999
user2887097 Avatar asked Dec 18 '13 14:12

user2887097


2 Answers

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

// Objective-C
buttonOutline.antialiased = NO

// Swift
buttonOutline.antialiased = false
like image 71
Santiago Tactivos Avatar answered Nov 08 '22 21:11

Santiago Tactivos


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

like image 23
Artur Konarski Avatar answered Nov 08 '22 22:11

Artur Konarski