gpt4 book ai didi

android-studio - libgdx android studio - 无法解析方法drawMultiLine和符号HAlignment

转载 作者:行者123 更新时间:2023-12-03 16:54:01 26 4
gpt4 key购买 nike

在尝试构建/运行时,我在 android studio 和 libgdx 中遇到了这个错误:

Error:(118, 79) Gradle: error: cannot find symbol variable HAlignment



并且android studio还在源代码java类中将“drawMultiLine”和“HAlignment”标记为红色:

"Cannot resolve method 'drawMultiLine(com.badlogic.gdx.graphics.g2d.SpriteBatch, java.lang.String, float, float, int, ?)'" "Cannot resolve symbol HAlignment"



代码块:
private void renderGuiGameOverMessage (SpriteBatch batch)
{
float x = cameraGUI.viewportWidth / 2;
float y = cameraGUI.viewportHeight / 2;
if (worldController.isGameOver())
{
BitmapFont fontGameOver = Assets.instance.fonts.defaultBig;
fontGameOver.setColor(1, 0.75f, 0.25f, 1);
fontGameOver.drawMultiLine(batch, "GAME OVER", x, y, 0, BitmapFont.HAlignment.CENTER);
fontGameOver.setColor(1, 1, 1, 1);
}
}

为什么找不到方法?
我该如何解决这个问题?

非常感谢!

最佳答案

试试这个:

fontGameOver.drawMultiLine(batch, "GAME OVER", x, y, 0, Align.center);

代替:
fontGameOver.drawMultiLine(batch, "GAME OVER", x, y, 0, BitmapFont.HAlignment.CENTER);

注意需要导入 com.badlogic.gdx.utils.Align现在。

bitmapfont refactoring post from the badlogicgames blog 来看这应该适合你。尤其看这几点:

BitmapFont.HAlignment is gone. Align is used instead. Align has been moved to the utils package.

关于android-studio - libgdx android studio - 无法解析方法drawMultiLine和符号HAlignment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30831038/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com