libgdx 如何缩放 BitmapFont 以更改屏幕尺寸?
问题描述
我想要的是在更改屏幕尺寸时相应地更改大小的位图字体.我的意思是在我的电脑上,字体看起来相当大,但在我的手机上,它是一种难以阅读的小字体.我可以更改大小,但我希望它在所有屏幕上看起来都相似,而不是在一个屏幕上大而在另一个屏幕上小.这是我的代码,看看我必须使用什么:
What I want to have is the Bitmap Font to change in size accordingly when changing screen sizes. What I mean is on my computer, the font appears rather large, but on my phone, it is a little font that is harder to read. I could change the size, but I want it to look similar on all screens, instead of having it large on one screen and smaller on another. Here is my code to see what I have to work with:
推荐答案
这样想,你总是希望有相同的比例.
Think of it this way, you always want to have the same ratio.
例如:
500/3 = 450/x
500/3 = 450/x
x 是文本的新大小.所以你必须做一些交叉乘法.
x is the new size of your text. So you have to do some cross multiplying.
500x = 1350
500x = 1350
1350÷500 = x
1350÷500 = x
所以现在以编程方式执行此操作.
So now to do this programmatically.
你还说它需要根据大小超过一定数量而改变.
Also you said that it needs to change depending on of the size is over a certain amount.
所以这是我设计的一个小东西
So here's a little thing I've devised
这篇关于libgdx 如何缩放 BitmapFont 以更改屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!