简体   繁体   English

在libgdx Java中滚动文本

[英]Scrolling text in libgdx java

I am trying to get text to slowly print one character within a string at a time so the text appears to be printed out and scrolling. 我正在尝试使文本每次一次缓慢地在字符串中打印一个字符,以使文本看起来像是被打印出来并滚动了。 I can't seem to find where the answer lies. 我似乎找不到答案在哪里。 Here is what I have tried 这是我尝试过的

public void render(SpriteBatch batch) {
    for(int i = 0; i < text.length(); i++){
        e += Gdx.graphics.getDeltaTime();
        if(e > 5f){
            System.out.println(e);
            tmp+= text.substring(i, i+1);
            glyph.setText(font, tmp);
            font.draw(batch, glyph, 100 + glyph.width, 100);
            e = 0;
            i++;
            continue;
        }
    }
}

However the text just zooms off the screen. 但是,文本只是在屏幕上缩小。 Any help in accomplishing the smooth one character at a time printing is extremely appreciated! 非常感谢您一次完成一个平滑字符的任何帮助!

您需要在绘图调用100 + glyph.width删除该行,它可以完美地工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM