I used a relatively small image (44pixel tall) and scaled it up to have a pixel art look. I tried to change the filtering mode to nearest so the anti-aliasing would disappear but it didn't. It appears with blurry edges. I tried the same with a background getting the same result.
let myNode = SKSpriteNode()
class GameScene: SKScene {
func makeNode() {
myNode.position = CGPoint(x: self.frame.size.width/2, y: self.frame.size.height/2)
myNode.size = CGSize(width: 200, height: 200)
myNode.texture = SKTexture(imageNamed: "image")
myNode.texture!.filteringMode = .Nearest
return self.addChild(myNode)
}
}
override func didMoveToView(view: SKView) {
makeNode()
}
UPDATE: SKTexture nearest filtering mode is now working in Xcode 7 GM. No need to manually scale images as I've suggested below.
I am experiencing this same problem in Xcode 7 beta 5 with beta iOS 9 ; the Nearest filtering mode is seemingly ignored. In my project, scaling with nearest-neighbor scaling was previously working in Xcode 6 on iOS 8.
In the event that the bug is not resolved before the final release of iOS 9 I am pre-scaling images before I place them in their respective atlases.
To do this I wrote a simple python script to recursively find png files and scale them using imagmagick.
If you don’t have imagemagick installed, you can install it using macports like so:
If you have homebrew it looks like this:
I just place this script (below) in a file called imgscaler.py within the directory above my atlas files (which I want to scale by 400% in my case) and kick it off from the terminal:
The script looks like this:
Change
scale_percentage
to whatever percentage you want to scale by.BTW, I am guessing this scaling issue will eventually get resolved. I’m currently updating my code with this assumption in mind. This is just a bandaid in the event the fix to nearest-neighbor scaling in SpriteKit arrives later than iOS 9.0.
This is a bug in Xcode7 beta / iOS9. It works if you use Xcode 6.