【问题标题】:Irregular font spacing in LibGDXLibGDX中的不规则字体间距
【发布时间】:2016-06-22 12:28:14
【问题描述】:

我正在使用 LibGDX 开发这款游戏,并且我有一个 BitmapFont 用于在屏幕上写下分数。字体以奇怪的间距出现,并且在移动时会发生变化。我该如何解决?以下是文本显示方式的一些示例:

这是字体的代码:

generator = new FreeTypeFontGenerator(Gdx.files.internal("font/komika.ttf"));
parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 100;
defaultFont = generator.generateFont(parameter);

这是标签的代码:

topScoreLabel = new Label(String.valueOf("Best : " + topScore), skin);
topScoreLabel.setColor(Color.RED);
topScoreLabel.setBounds(GAME_WORLD_WIDTH - 30, GAME_WORLD_HEIGHT - 20 * aspectRatio, 25, 20 * aspectRatio);
topScoreLabel.setFontScale(0.05f);
topScoreLabel.setAlignment(Align.right);

我使用这么大的字体是因为它应该可以在大屏幕上很好地缩放,如果我有更小的字体就不会。我该如何解决这个问题?

【问题讨论】:

    标签: android fonts libgdx bitmap-fonts


    【解决方案1】:

    使用font.setUseIntegerPositions(false)。它默认开启,因为文本通常与像素完美的相机/视口一起使用,并且如果精灵与屏幕像素对齐,则看起来不太模糊。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-13
      • 2014-08-12
      • 2015-02-09
      • 2021-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多