iossprite-kitsklabelnode

How to disable anti-aliasing in SKLabelNode?


I want to use a pixel font in my SpriteKit game.
But I can't use a bitmap font because I need to support many languages (too many characters).
So I should use a ttf font file.

I tried the following code, but characters were blurred by anti-aliasing.

let myLabel = SKLabelNode(fontNamed:"My-Pixel-Font")
myLabel.text = "Hello"
myLabel.fontSize = 10
myLabel.position = CGPoint(x: 100.0, y: 100.0)
myLabel.fontColor = SKColor.GrayColor()
self.addChild(myLabel);

Is there a good way to disable anti-aliasing in SKLabelNode?

My English is not good.
Thank you.


Solution

  • You can call [textureFromNode:] method on your SKView to get your SKLabelNode's texture, set it's filteringMode property to SKTextureFilteringNearest and create new SKSpriteNode with that texture.