ios - 使用 SKSpriteNode 缩放时的像素化圆圈

标签 ios swift sprite-kit

当缩小图像时,圆周会像素化。

嵌入的圆形图像的半径为 100 像素。 (圆圈是白色的,所以点击空白处,你会得到图像。)使用 SpriteKit 缩小会导致边框变得非常模糊和像素化。如何在 SpriteKit 中放大/缩小并保留清晰的边界?目标是使用圆形的基础图像,并使用该基础图像创建不同大小的圆形图像。

White circle

    // Create dot
    let dot = SKSpriteNode(imageNamed: "dot50")

    // Position dot
    dot.position = scenePoint

    // Size dot
    let scale = radius / MasterDotRadius
    println("Dot size and scale: \(radius) and \(scale)")
    dot.setScale(scale)

    dot.texture!.filteringMode = .Nearest

最佳答案

看来你应该使用 SKTextureFilteringLinear 而不是 SKTextureFilteringNearest:

SKTextureFilteringNearest:

Each pixel is drawn using the nearest point in the texture. This mode is faster, but the results are often pixelated.

SKTextureFilteringLinear:

Each pixel is drawn by using a linear filter of multiple texels in the texture. This mode produces higher quality results but may be slower.

您可以使用 SKShapeNode,它在缩放动画时会表现得更好,但最终结果(当点缩放到某个值时)将几乎像素化,就像使用 SKSpriteNode 和图像时一样。

关于ios - 使用 SKSpriteNode 缩放时的像素化圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30062287/

相关文章:

ios - 如何在 Sprite 套件项目中设置初始场景?

ios - 在数组的不同部分多次调用相同的方法

ios - 从上到下方向呈现 View Controller

ios - 使用 ImageView 与程序化 Segue 进行挑战

objective-c - 界面生成器中的关键命令是什么

sprite-kit - 对字体进行轮廓或阴影处理的最佳方法是什么?

iphone - API key 必须在每个请求中作为 API-Key header 传递

iphone - UINavigationController - 实现返回开始按钮

ios - 快速重新安装应用程序后 iCloud 文件不可见

performance - 雪碧包 : Efficiently create many SpriteNodes