TypingLabel - Simulates text being typed in real time.

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

Re: TypingLabel - Simulates text being typed in real time.

Postby RafaSKB » Sat Feb 25, 2017 2:58 am

Uh oh, I see what you mean, I'm working on it right now. Thanks for the report! :)
Awesome libGDX - A curated list of resources and tutorials to help developers make awesome games. https://github.com/rafaskb/awesome-libgdx#readme

Grashers - Trash-themed roguelike set in space. http://www.grashers.com
RafaSKB
 
Posts: 142
Joined: Sat Aug 01, 2015 5:14 am
Location: São Paulo, Brazil

Re: TypingLabel - Simulates text being typed in real time.

Postby RafaSKB » Sat Feb 25, 2017 10:37 am

Version 1.0.2 released, update your gradle files.

- Added a way to replace variables through a listener method, instead of having to provide fixed values.
- Effect tokens now end previous effects of the same type, to prevent similar effects to stack.
- Dispose cached glyphs when label is removed from its parent.
- Fixed bug causing restart() to not actually restart the text when called from listener.end().
- Fixed bug causing weird effects to glyphs, especially on wrapped labels.
- Fixed text effects ending at the wrong character.
- Fixed events being fired at the wrong character.
Awesome libGDX - A curated list of resources and tutorials to help developers make awesome games. https://github.com/rafaskb/awesome-libgdx#readme

Grashers - Trash-themed roguelike set in space. http://www.grashers.com
RafaSKB
 
Posts: 142
Joined: Sat Aug 01, 2015 5:14 am
Location: São Paulo, Brazil

Re: TypingLabel - Simulates text being typed in real time.

Postby emupaul » Sun Feb 26, 2017 12:45 am

*edit* - I was able to get Variable replacement to work after setting the gradle build to 1.0.1, this feature seems broken in 1.0.2.

Cant seem to get {VAR=var_name} functionality working. I'm adding the TypingText to a table. It doesn't matter if I execute .setVariable(..,..) directly after creating the label or later in another function. It just doesn't appear to update anything at all. The texts shakes and does everything else it should, except display the variable string.

thoughts? Am i doing something wrong here?

...
Code: Select all
...
nameLabel = new TypingLabel("{SHAKE} My name is... {VAR=_name}", new TypingLabel.LabelStyle(font, Color.WHITE));
nameLabel.setVariable("_name","uncommon name");
...
table.add(portrait).pad(5).padRight(55).padTop(75);
table.add(nameLabel).pad(10).top();
...
emupaul
 
Posts: 2
Joined: Sun Feb 26, 2017 12:35 am

Re: TypingLabel - Simulates text being typed in real time.

Postby wizered67 » Sun Feb 26, 2017 3:22 am

Great work on the bug fixes, that was really fast! I've been working still on replacing my old code with this and I've had a lot of success so far! I was able to get the variable replacement and the events I needed to work! I've had to use a bit of a workaround (long story, but I'm extending TypingLabel to be able to call act when I want, multiple times per frame if all text should be displayed) but I also have the text effects working!

There is one thing I have not gotten working yet, and the workaround is a little clunky. I want to play a sound effect when text is added, as long as the text added isn't empty (ie all whitespace). Right now my thoughts are that I would have to keep track of all text being displayed and then, after the text updates, getting all the new text being displayed and comparing the two. Would you consider adding a way to retrieve the characters that were added each time act is called? I've looked through the code and I believe you're already getting each added character in order to update the cooldown, so I don't think it would be too difficult to store all the characters added in each update and let them be retrieved somehow.

Thanks again so much for all the hard work on this! You have no idea how great it felt to delete all my old code, full of "todo"s and "fixme"s after replacing it with this!
wizered67
 
Posts: 19
Joined: Wed May 25, 2016 6:32 am

Re: TypingLabel - Simulates text being typed in real time.

Postby RafaSKB » Sun Feb 26, 2017 8:39 am

emupaul wrote:*edit* - I was able to get Variable replacement to work after setting the gradle build to 1.0.1, this feature seems broken in 1.0.2.

Cant seem to get {VAR=var_name} functionality working. I'm adding the TypingText to a table. It doesn't matter if I execute .setVariable(..,..) directly after creating the label or later in another function. It just doesn't appear to update anything at all. The texts shakes and does everything else it should, except display the variable string.

thoughts? Am i doing something wrong here?


Hey emupaul, you're not doing anything wrong, this is indeed a bug with the library. As a workaround for 1.0.2 you can set an empty listener to the label, that will make it work.
Code: Select all
 nameLabel.setTypingListener(new TypingAdapter());


This happens because the new feature of replacing variables through this listener, instead of fixed values, for more flexibility, however I forgot to test the scenario where no listener is used at all. It will be fixed in the next version. Thanks for the report! :)


wizered67 wrote:I've had to use a bit of a workaround (long story, but I'm extending TypingLabel to be able to call act when I want, multiple times per frame if all text should be displayed)

If you mean you want to get all text to show up when the user press some buttons, as if they were skipping the text progression, you can just call label.skipToTheEnd();

wizered67 wrote:I want to play a sound effect when text is added, as long as the text added isn't empty (ie all whitespace). Right now my thoughts are that I would have to keep track of all text being displayed and then, after the text updates, getting all the new text being displayed and comparing the two. Would you consider adding a way to retrieve the characters that were added each time act is called?

Yesss that's definitely planed, in fact it was one of the reasons I made this library in the first place, I'll do my best to include this in the next version :)

And I'm really glad you are enjoying the library! I always thought it was weird that you couldn't do typing texts like this in libGDX, while all other engines have it, and it feels good to give a little bit back to this awesome open source community, so enjoy! :D
Awesome libGDX - A curated list of resources and tutorials to help developers make awesome games. https://github.com/rafaskb/awesome-libgdx#readme

Grashers - Trash-themed roguelike set in space. http://www.grashers.com
RafaSKB
 
Posts: 142
Joined: Sat Aug 01, 2015 5:14 am
Location: São Paulo, Brazil

Re: TypingLabel - Simulates text being typed in real time.

Postby wizered67 » Sun Feb 26, 2017 9:11 am

Glad to hear that the feature is planned! Yeah, I knew about skipToTheEnd, but my scenario is a bit more complicated because even when skipping, commands (events) in the text can activate that pause the text until they complete. I wanted to keep my code structured like before to have control over when the text is updated. Right now my code is something like
While there is text remaining and a command is not pausing the text: call the act method, and then break from the loop if all text shouldn't be displayed. Otherwise continue to loop until all the text has been displayed or a command pauses it.

Admittedly I may have been a bit too stubborn about keeping my code like it was before. I've had to do some work arounds to always update the effects but not always update the text itself. I guess I could probably avoid the issue by using pause(), resume(), and skipToTheEnd(), but I believe I would need a way to stop skipping to the end, and from my limited experimentation I don't believe pause() works for that. If you have any thoughts on the best way to do what I'm trying to do, I'm open to suggestions!
wizered67
 
Posts: 19
Joined: Wed May 25, 2016 6:32 am

Re: TypingLabel - Simulates text being typed in real time.

Postby RafaSKB » Sun Feb 26, 2017 9:49 am

Alright I see why you need that. How about you call skipToTheEnd(false), which doesn't ignore events, and at some specific event you call cancelSkipping() to restore the label's normal behavior? Optionally followed by pause().

cancelSkipping() is not an actual method yet, but I already coded it here and it works nicely. Would that do the job for you?
Awesome libGDX - A curated list of resources and tutorials to help developers make awesome games. https://github.com/rafaskb/awesome-libgdx#readme

Grashers - Trash-themed roguelike set in space. http://www.grashers.com
RafaSKB
 
Posts: 142
Joined: Sat Aug 01, 2015 5:14 am
Location: São Paulo, Brazil

Re: TypingLabel - Simulates text being typed in real time.

Postby wizered67 » Sun Feb 26, 2017 9:54 am

Yeah, that definitely sounds like a cleaner solution and I think it should work. Thanks!
wizered67
 
Posts: 19
Joined: Wed May 25, 2016 6:32 am

Re: TypingLabel - Simulates text being typed in real time.

Postby RafaSKB » Sun Feb 26, 2017 12:43 pm

Version 1.0.3 released.

- API Addition: Notify listener about character progression through the method onChar(Character).
- API Addition: Added cancelSkipping(), which can be called during events after skipToTheEnd() is called.
- Fixed variables not being replaced without having a listener set.
- Fixed exception when using null as text.
Awesome libGDX - A curated list of resources and tutorials to help developers make awesome games. https://github.com/rafaskb/awesome-libgdx#readme

Grashers - Trash-themed roguelike set in space. http://www.grashers.com
RafaSKB
 
Posts: 142
Joined: Sat Aug 01, 2015 5:14 am
Location: São Paulo, Brazil

Re: TypingLabel - Simulates text being typed in real time.

Postby emupaul » Sun Feb 26, 2017 3:32 pm

Thank you!, tested 1.0.3, it works better now. If your open to suggestions, could I suggest a BLINK token with a speed of blink setting associated with it?
emupaul
 
Posts: 2
Joined: Sun Feb 26, 2017 12:35 am

PreviousNext

Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest