Is it possible to fix the fuzziness of antialiased SKShapeNodes?

前端 未结 2 2110
没有蜡笔的小新
没有蜡笔的小新 2021-02-14 09:14

I\'m experimenting with using SKShapeNodes in a game, and have found that antialiased SKShapeNodes are very blurry.

Without antialiasing:

相关标签:
2条回答
  • 2021-02-14 09:51

    Nope—that’s what “antialiasing” looks like on a shape node. You might be expecting to see something more like multisampling, but that’s not what SpriteKit is doing here. To get the smooth non-blurry lines you’re looking for you’ll have to draw your shapes into an image and then display that in an SKNode. You might also consider filing an enhancement request on the API.

    0 讨论(0)
  • 2021-02-14 10:03

    This is not a pretty solution, but it does work: Create a bigger SKShapeNode and scale it down.

    Normal:

    let shape = SKShapeNode(circleOfRadius: 10)
    

    Scaled:

    let scaleFactor: CGFloat = 2
    let shape = SKShapeNode(circleOfRadius: 10 * scaleFactor)
    shape.xScale = 1 / scaleFactor
    shape.yScale = 1 / scaleFactor
    

    This makes the render appear much less fuzzy, but be warned, it can cause frustrating issues when adding SKNodes as children, because they may be recursively scaled and end up smaller than you expect.

    0 讨论(0)
提交回复
热议问题