From 6c4e883810a09bc047926ef7f7c1e7268c0387a8 Mon Sep 17 00:00:00 2001 From: GammelJAN Date: Sun, 24 Jan 2021 13:54:40 +0100 Subject: [PATCH] textbox edited --- core/src/com/trs/main/Textbox.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/src/com/trs/main/Textbox.java b/core/src/com/trs/main/Textbox.java index 5225dc7..2028bf6 100644 --- a/core/src/com/trs/main/Textbox.java +++ b/core/src/com/trs/main/Textbox.java @@ -25,8 +25,9 @@ public class Textbox extends Actor{ BitmapFont font; Rectangle r; - int printLine; - int printChar; + float printChar; + + float textSpeed = 0.8f; //ArrayList splitted; ShapeRenderer renderer; @@ -51,7 +52,6 @@ public class Textbox extends Actor{ renderer = new ShapeRenderer(); textHeight = getTextHeight(font,"A"); - printLine = 0; printChar = 0; this.ans = ans; setName("textbox"); @@ -86,7 +86,6 @@ public class Textbox extends Actor{ setBounds(r.getX(), r.getY(), r.getWidth(), r.getHeight()); renderer = new ShapeRenderer(); - printLine = 0; printChar = 0; setName("textbox"); this.toPrint = t.toPrint; @@ -102,7 +101,6 @@ public class Textbox extends Actor{ r = new Rectangle(getX(), getY(), getWidth(), 0); setBounds(r.getX(), r.getY(), r.getWidth(), r.getHeight()); this.state = 0; - printLine = 0; printChar = 0; selectedAsw = 0; } @@ -136,7 +134,7 @@ public class Textbox extends Actor{ state = 1; } else{ - printChar++; + printChar+=textSpeed; } if(Gdx.input.isKeyJustPressed(Input.Keys.ENTER)){ state = 1; @@ -161,7 +159,7 @@ public class Textbox extends Actor{ int alignment = -1; font.setColor(Color.CLEAR); - float height = font.draw(batch, toPrint.substring(0, printChar), getX()+2, getY(), getWidth(), alignment, true).height+5; + float height = font.draw(batch, toPrint.substring(0, (int)printChar), getX()+2, getY(), getWidth(), alignment, true).height+5; float textHeight = height; for(String s : ans){ height += getTextHeight(font, "A") + 10; @@ -182,7 +180,7 @@ public class Textbox extends Actor{ batch.begin(); - font.draw(batch, toPrint.substring(0, printChar), getX()+2, getY()+getHeight()-3, getWidth(), alignment, true); + font.draw(batch, toPrint.substring(0, (int)printChar), getX()+2, getY()+getHeight()-3, getWidth(), alignment, true); if(state == 1){ for(int i = 0; i < ans.length; i++){