更改皮肤中的字体大小 [英] Changing font size in skin
问题描述
我正在使用libgdx编写游戏,并从教程中借用了skin.json(和相关文件)。
I am writing a game using libgdx, and I borrowed the skin.json (and related files) from a tutorial.
使用的字体(默认)是在更密集的屏幕上以丑陋的方式缩放,所以我通过自己非常大的字体生成 - 在游戏本身中,我将其缩放到合理的大小(基本上我使用 BitmapFont.scale
)。我现在使用的字体是前一个字体的3倍。
The font being used (default) was scaling in an ugly manner on denser screens, so I generated by own very large font - and in the game itself, I scale it to a reasonable size (basically I use BitmapFont.scale
). The font I'm now using is 3 times as large as the previous one.
我更改了对skin.json文件中使用哪种字体的引用,以及结果,我的所有按钮,标题和其他东西都显示了一个巨大的字体。
I changed the reference to which font to use in the skin.json file, and as a result, all my buttons, titles and other things have a massive font being shown.
有没有办法缩放.json文件中的字体?或者代码中的其他任何地方? Skin没有 setFont()
功能,因此我无法创建缩放的BitmapFont并分配它。
Is there a way of scaling the font in the .json file? Or anywhere else in the code? Skin doesn't have a setFont()
functionality, so I can't create a scaled BitmapFont and assign it)
推荐答案
文档说任何获取都将返回实际对象的句柄。因此,更改将持续存在。
Documentation says that any gets will return a handle to the actual object. So changes will persist.
所以我将skin.json中的字体更改为指向我的新字体。
So I changed the font in skin.json to point to my new font.
然后我使用了这段代码
this.getSkin().getFont("default-font").setScale(0.33f, 0.33f);
将'default-font'(在skin.json中定义)缩放到比例I想要(在我的情况下是0.33f)
To scale the 'default-font' (as defined in the skin.json) to the scale I wanted (in my case its 0.33f)
这篇关于更改皮肤中的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!