问题描述
我想在SpriteKit游戏中使用像素字体.
但是我不能使用位图字体,因为我需要支持多种语言(字符过多).
所以我应该使用ttf字体文件.
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);
在SKLabelNode中是否有禁用抗锯齿的好方法?
Is there a good way to disable anti-aliasing in SKLabelNode?
我的英语不好.
谢谢.
My English is not good.
Thank you.
推荐答案
您可以在SKView
上调用[textureFromNode:]
方法来获取SKLabelNode
的纹理,将其filteringMode
属性设置为SKTextureFilteringNearest
,然后用该纹理创建新的SKSpriteNode
.
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.
这篇关于如何在SKLabelNode中禁用抗锯齿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!