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