libgdx android studio - 无法解析方法 drawMultiLine 和符号 HAlignment
libgdx android studio - cannot resolve method drawMultiLine and symbol HAlignment
我在 android studio 和 libgdx 中遇到此错误,当我尝试 build/run:
Error:(118, 79) Gradle: error: cannot find symbol variable HAlignment
和android studio也在源代码中将"drawMultiLine"和"HAlignment"标记为红字java class:
"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 中遇到此错误,当我尝试 build/run:
Error:(118, 79) Gradle: error: cannot find symbol variable HAlignment
和android studio也在源代码中将"drawMultiLine"和"HAlignment"标记为红字java class:
"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.