Libgdx 弃用 drawMultiLine 和 getBounds

Libgdx deprecated drawMultiLine and getBounds

所以我找到了一个创建视觉小说的工具包,但它使用

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

  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++;

我是 Java 的新手,我不知道如何将所有代码更改为 wiki 所说的内容:

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

它说我应该用 Glyph 替换 getBounds 但 getBounds 没有评论,我不确定它的作用

根据弃用说明,而不是

font.getBounds(myText).width

你应该使用:

new GlyphLayout(font, myText).width 

(这​​只是一个指针,你应该优化它,不要每次都创建新对象)