Closed Cigeea closed 4 years ago
Hi, thanks for reporting the issue!
As the setText
docs say, restart()
should be used instead, but I understand this doesn't feel like the right behavior. That means we have to change how setText
works in a way that doesn't hurt games using the current behavior, and works when label is yet not typed, is being typed, and is completely typed, both for longer and shorter strings.
Here's a few ideas:
setText
is used, as you suggested.setText
and ask developers to use restart
instead, if they want the "typing" effect, but that would break most games using it I think.I'm not in love with any of them yet so I'll keep thinking about the issue.
I ended up taking a hybrid approach here.
If setText
is called after the char progression is already running, then the label is restarted.
However if the label's char progression is already ended (see hasEnded()
), then the label skips to the end automatically.
The settext method does not work as intended: after a first call to draw has been done on the label with a given text A of n characters, the setText(Text B) method will only print the first n characters of Text B.
To reproduce this bug easily, I modified the TypingLabelTest class by removing all the text.append calls in the createTypingLabel method. I then added two calls to text.append("12"); and text.append("34");
In the render method, under the stage.draw() call, add if(Gdx.input.isKeyJustPressed(Keys.ENTER)) { // label.restart(); label.setText("This is a dummy text that will be cut"); }
Now if you launch you will see an expected "1234" appearing normally on the screen, but after pressing the enter key, only the "This" will be printed. If you click on restart the whole text appears normally.
My conclusion is that every call to the setText method must be accompanied by a label.restart call.
I don't think this is an intended feature since switching to a regular Label label object doesn't reproduce this.