0 votes

Hi everyone! I'm trying to make Label node behave in particular way but so far without success. This is the behavior I want:

  • Show maximum of 4 lines for a text that is longer than that
  • Gradually reveal every letter by "visible_characters" property, but only for the 4 lines
  • When all 4 lines are revealed, show blinking "continue" indicator
  • After a key press show another 4 lines (or less if it's the end of the text) with "skipped line" property and begin the "visible characters" animation again

However I'm stuck because I have no idea how to get the information about the text box being full (showing 4 lines) so I can show the "continue" indicator. I would be glad for any kind of help.

The best way would be making the system dynamic so I don't have to format the text manually with every change in the Label node size.

Thanks!

Godot version 3.4.4
in Engine by (72 points)

A Label has two methods that are probably helpful here...

get_line_count() - returns the number of text lines in the label
get_visible_line_count() - returns the number of visible lines in the label

Additionally, there are a few other methods that could be helpful in your solution. See the docs here.

Those two functions are helpful, unfortunately not as much as I would love to.

get_line_count() gives me all lines in the Label.
get_visible_line_count() gives me number of visible lines in the Label, BUT (!) counting even characters that are not yet visible.

That means, when showing one character after another, I have no way of knowing if I show characters from the first four lines or from the others that are out of textbox boundaries.

{marked as deleted}

1 Answer

0 votes

I've managed to make it work. Had to write my own logic how to split the continuous text into separate segments. First, I've split the text into tokens using " " as delimiter and then been puttin word by word into the Label. When the text has overflown the Label (get_line_count() was bigger than the maximum number of lines I wanted to show), I've created a segment and start over with the rest of the words. Works nicely.
How much easier would it be if we had somethin like get_visible_characters() method.

by (72 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.