Problem with automatic line break and text flow

Anything libgdx related goes here!

Problem with automatic line break and text flow

Postby StarCloud » Tue Aug 20, 2019 6:17 pm

I don't know if I do something wrong or if it just is like that.
Sometimes the text awkwardly stops and goes to the next line.

Image

It writes "para" and then it removes "para" and continues at the second line.

Image


This is how I draw the string:

Code: Select all
currentTextString="Have you tried a \"Mindbreaker\" yet? This parasite was recently discovered.";
font.draw(batch, currentTextString.substring(0, (int)textDrawLength), 0,0, 663,Align.left,true);


I increase the text flow:

Code: Select all
 if ((int)textDrawLength < currentTextString.length())
    {
        textDrawLength+=(0.5f*TEXTSPEED);
    }           
   


It's not a big deal breaker, just looks a little weird.
StarCloud
 
Posts: 26
Joined: Wed Oct 24, 2018 6:58 pm
Location: Tammisaari

Re: Problem with automatic line break and text flow

Postby evilentity » Tue Aug 20, 2019 7:00 pm

How do you expect it to know that 'para' will change into 'parasite' or whatever else? It just fits whatever it has right now.

Perhaps this will be a better choice, if you are already not using it https://github.com/rafaskb/typing-label
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4854
Joined: Wed Aug 24, 2011 11:37 am

Re: Problem with automatic line break and text flow

Postby StarCloud » Tue Aug 20, 2019 7:34 pm

evilentity wrote:How do you expect it to know that 'para' will change into 'parasite' or whatever else? It just fits whatever it has right now.

Perhaps this will be a better choice, if you are already not using it https://github.com/rafaskb/typing-label


Yeah thats what I ment, if there is a way so it knows that the word is too long too display and instead draws it on the next line.
I checked the link but I already am confused at the installation

Open build.gradle in project root and add this to the ext section under allprojects:


I don't know how to open build.gradle, do I need another software? I will check into this.
StarCloud
 
Posts: 26
Joined: Wed Oct 24, 2018 6:58 pm
Location: Tammisaari

Re: Problem with automatic line break and text flow

Postby shatterblast » Tue Aug 20, 2019 10:53 pm

It should open with any "normal" text editor. IntelliJ by default should open it just fine. You may have to assign your computer of choice to open the document with a specific text editor, assuming you do not use an IDE, like IntelliJ. However, I wouldn't use a "normal" text editor unless you know it will handle your code fine. Certain things, like WordPad, can un-intentionally break code.
shatterblast
 
Posts: 414
Joined: Sun Jul 06, 2014 1:14 pm

Re: Problem with automatic line break and text flow

Postby StarCloud » Wed Aug 21, 2019 10:07 am

shatterblast wrote:It should open with any "normal" text editor. IntelliJ by default should open it just fine. You may have to assign your computer of choice to open the document with a specific text editor, assuming you do not use an IDE, like IntelliJ. However, I wouldn't use a "normal" text editor unless you know it will handle your code fine. Certain things, like WordPad, can un-intentionally break code.


I added this code in my build.gradle file, but what am I suppose to do now?
If I try to use
Code: Select all
TypingLabel label = new TypingLabel("Hello world!", skin);


It can't find the class. Do I have to download this files and put them in my project?

Image

Whatever, I just do it manuelly and put \n everywhere it looks weird.
StarCloud
 
Posts: 26
Joined: Wed Oct 24, 2018 6:58 pm
Location: Tammisaari


Return to Libgdx

Who is online

Users browsing this forum: MSN [Bot] and 1 guest