mardi 5 mai 2015

Pixelated circles when scaling with SKSpriteNode

The perimeter around a circle gets pixelated when scaling down the image.

The embedded circle image has a radius of 100 pixels. (The circle is white so click around the blank space, and you'll get the image.) Scaling down using SpriteKit causes the border to get very blurry and pixelated. How to scale up/down and preserve sharp borders in SpriteKit? The goal is to use a base image for a circle and create circle images of different sizes with this one base image.

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

Aucun commentaire:

Enregistrer un commentaire