【问题标题】:Unable to call the scale() method in Libgdx for android无法在 Libgdx for android 中调用 scale() 方法
【发布时间】:2015-05-04 06:50:03
【问题描述】:

我从今天开始通过查看一些教程开始学习 Libgdx,发现这个框架非常好,但是,我遇到了一个小问题。我已经使用 BitmapFont 设置了字体,并试图使用一种方法来缩放文本的大小,但是,我找不到 scale() 方法。我忘了导入什么东西吗?或者也许错过了什么?

我已经为private BitmapFont font; 导入了import com.badlogic.gdx.graphics.g2d.BitmapFont; 我可以使用font.setColor(Color.GREEN); 更改字体的颜色但是我无法调用一些方法来缩放文本。我应该导入整个东西吗?还是我应该首先添加额外的库?我已经列出了我在我的活动中拥有的所有导入。

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;

【问题讨论】:

    标签: android libgdx


    【解决方案1】:

    不要使用比例。缩放字体看起来很糟糕,应该避免。相反,请使用 LibGDX 的 FreeTypeFontGenerator 为您的应用程序生成正确大小的 BitmapFont,而无需任何缩放。

    https://github.com/libgdx/libgdx/wiki/Gdx-freetype

    【讨论】:

      猜你喜欢
      • 2023-03-06
      • 2018-07-29
      • 2022-01-19
      • 1970-01-01
      • 2016-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-03
      相关资源
      最近更新 更多