Libgdx android studio - cannot resolve drawMultiLine method and HAlignment character

I ran into this error in android studio and libgdx when trying to build / run:

Error: (118, 79) Gradle: error: Cannot find symbolic variable HAlignment

And android studio also marks "drawMultiLine" and "HAlignment" as red word in the source java class:

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

Code block:

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);
    }
}

      

Why doesn't he find a method? How can I solve this?

Thank you so much!

+3


source to share


1 answer


Try the following:

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

      

instead:

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

      



Please note that you need to import com.badlogic.gdx.utils.Align

now.

Judging by the bitmapfont refactoring post from the badlogicgames blog , this should work for you. Especially it concerns:

BitmapFont.Alignment is gone. Align is used instead. The alignment has been moved to the utils package.

+2


source







All Articles