<tfoot id='wXGEr'></tfoot>

        <legend id='wXGEr'><style id='wXGEr'><dir id='wXGEr'><q id='wXGEr'></q></dir></style></legend>

      1. <small id='wXGEr'></small><noframes id='wXGEr'>

        • <bdo id='wXGEr'></bdo><ul id='wXGEr'></ul>
        <i id='wXGEr'><tr id='wXGEr'><dt id='wXGEr'><q id='wXGEr'><span id='wXGEr'><b id='wXGEr'><form id='wXGEr'><ins id='wXGEr'></ins><ul id='wXGEr'></ul><sub id='wXGEr'></sub></form><legend id='wXGEr'></legend><bdo id='wXGEr'><pre id='wXGEr'><center id='wXGEr'></center></pre></bdo></b><th id='wXGEr'></th></span></q></dt></tr></i><div id='wXGEr'><tfoot id='wXGEr'></tfoot><dl id='wXGEr'><fieldset id='wXGEr'></fieldset></dl></div>
      2. libgdx 如何缩放 BitmapFont 以更改屏幕尺寸?

        时间:2023-05-19
        <tfoot id='61wpy'></tfoot>
            <tbody id='61wpy'></tbody>

          <i id='61wpy'><tr id='61wpy'><dt id='61wpy'><q id='61wpy'><span id='61wpy'><b id='61wpy'><form id='61wpy'><ins id='61wpy'></ins><ul id='61wpy'></ul><sub id='61wpy'></sub></form><legend id='61wpy'></legend><bdo id='61wpy'><pre id='61wpy'><center id='61wpy'></center></pre></bdo></b><th id='61wpy'></th></span></q></dt></tr></i><div id='61wpy'><tfoot id='61wpy'></tfoot><dl id='61wpy'><fieldset id='61wpy'></fieldset></dl></div>
          <legend id='61wpy'><style id='61wpy'><dir id='61wpy'><q id='61wpy'></q></dir></style></legend>

                <bdo id='61wpy'></bdo><ul id='61wpy'></ul>

                <small id='61wpy'></small><noframes id='61wpy'>

                • 本文介绍了libgdx 如何缩放 BitmapFont 以更改屏幕尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想要的是在更改屏幕尺寸时相应地更改大小的位图字体.我的意思是在我的电脑上,字体看起来相当大,但在我的手机上,它是一种难以阅读的小字体.我可以更改大小,但我希望它在所有屏幕上看起来都相似,而不是在一个屏幕上大而在另一个屏幕上小.这是我的代码,看看我必须使用什么:

                  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:

                  public void render() {
                      //score system
                      scoreFont.setColor(1.0f, 1.0f, 1.0f, 1.0f);
                      scoreBatch.begin(); 
                      scoreFont.draw(scoreBatch, Long.toString(getScore()), 10, Gdx.graphics.getHeight() - 10); 
                      scoreFont.setScale(3, 3);
                      scoreBatch.end();
                  }
                  
                  public void resize(int width, int height) {
                      camera.viewportWidth = 450;
                      camera.viewportHeight = 250;
                      camera.update();
                      stage.setViewport(450, 250, true);
                      stage.getCamera().translate(-stage.getGutterWidth(), -stage.getGutterHeight(), 0);
                  }
                  

                  推荐答案

                  这样想,你总是希望有相同的比例.

                  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.

                  public void resizeText(float width, float currentSize, float currentWidth){
                      //currentWidth/currentSize = width/x
                      a = width * currentSize;//450 * 3 in example above
                      b = a/currentWidth;
                      return b;//returns the x or the new size that your text should be
                  }
                  

                  你还说它需要根据大小超过一定数量而改变.

                  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

                  ApplicationType appType = Gdx.app.getType();
                     if (appType == ApplicationType.Android || appType == ApplicationType.iOS) {
                          screenFont.setScale(your number)
                      } else { screen font.setScale(otherNum)} //if its a desktop
                  

                  这篇关于libgdx 如何缩放 BitmapFont 以更改屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:是否可以在 libgdx 中扭曲演员 下一篇:如何使用 lib gdx 在 IntelliJ 中导入通用补间引擎

                  相关文章

                  最新文章

                  <legend id='xIWzX'><style id='xIWzX'><dir id='xIWzX'><q id='xIWzX'></q></dir></style></legend>

                  <tfoot id='xIWzX'></tfoot>
                • <i id='xIWzX'><tr id='xIWzX'><dt id='xIWzX'><q id='xIWzX'><span id='xIWzX'><b id='xIWzX'><form id='xIWzX'><ins id='xIWzX'></ins><ul id='xIWzX'></ul><sub id='xIWzX'></sub></form><legend id='xIWzX'></legend><bdo id='xIWzX'><pre id='xIWzX'><center id='xIWzX'></center></pre></bdo></b><th id='xIWzX'></th></span></q></dt></tr></i><div id='xIWzX'><tfoot id='xIWzX'></tfoot><dl id='xIWzX'><fieldset id='xIWzX'></fieldset></dl></div>

                        <bdo id='xIWzX'></bdo><ul id='xIWzX'></ul>
                    1. <small id='xIWzX'></small><noframes id='xIWzX'>