androidlibgdxbitmap-fonts

Libgdx deprecated drawMultiLine and getBounds


So i found a toolkit to create VisualNovels but it uses

        font.drawMultiLine(
               batch,
               previous.toString() + current.substring(0, c),
               dx, dy);

And

  else if (font.getBounds(test + words[i] + " ").width <= LINE_LENGTH) {
            if (i == (total - 1)){
                line.append(words[i]);
                linesArray.add(line.toString());
                lines++;
            }else
                line.append(words[i] + " ");
           }else if (font.getBounds(test + words[i] + " ").width > LINE_LENGTH){
                linesArray.add(test);
                line.replace(0, line.length(), words[i] + " ");
                lines++;

I'm Kinda new to Java and I don't know how to change all that code into what the wiki says:

http://www.badlogicgames.com/wordpress/?p=3658

It says that i should replace getBounds with Glyph but getBounds is not commented and I'm not sure what it does


Solution

  • According to the deprecation instructions, instead of

    font.getBounds(myText).width
    

    you should use:

    new GlyphLayout(font, myText).width 
    

    (This is just a pointer; you should optimize it and not create new objects every time)