本文介绍了如何在SKLabelNode中禁用抗锯齿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在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中禁用抗锯齿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:20