【问题标题】:How to set a lineWidth less than 1 for SKShapeNode?如何为 SKShapeNode 设置小于 1 的 lineWidth?
【发布时间】:2013-12-18 14:36:37
【问题描述】:

我正在尝试制作一个非常有创意的 SKShapeNode(例如 0.25 像素)。似乎 lineWidth 为 1 是我能走的最小的,至少这就是它在屏幕上的样子,不管设置了小于 1 的值。

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;

【问题讨论】:

    标签: ios objective-c sprite-kit skshapenode


    【解决方案1】:

    尝试将 antialiased 属性设置为 false。抗锯齿会在周围增加一些额外的像素。

    // Objective-C
    buttonOutline.antialiased = NO
    
    // Swift
    buttonOutline.antialiased = false
    

    【讨论】:

    • 谢谢,这行得通,我在文档中的任何地方都找不到这个
    【解决方案2】:

    将比例设置为 0.25 并记住正确放大坐标(在这种情况下乘以 4)

    【讨论】:

      猜你喜欢
      • 2017-01-07
      • 1970-01-01
      • 2016-01-29
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-26
      相关资源
      最近更新 更多