Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (762)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (847)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [libGDX] - Chat Bubble Recommendations?  (Read 2996 times)
0 Members and 1 Guest are viewing this topic.
Offline bsmith2

Senior Newbie

All about the iso

« Posted 2014-03-06 04:12:18 »

I am planning to implement chat bubbles above the heads of my actors. I could start hacking away and come up with a solution but wanted to gather some thoughts from others who may have implemented something similar with libGDX and get some recommendations on the best approach.

#1 - Use a custom draw method that autosizes itself and appears on screen using offsets from the player character and/or npc who is speaking. This would be easy to hack together, but could be challenging coming up with custom text wrapping and would take extra work to make the bubble actually look good.

#2 - Use a label widget from scene2d. I could add a label to the scene table that remains above the player's head but is invisible until text is ready to be shown. A timer could easily hide the box again after a few seconds. This seems reasonable for the player character but may not work for other non player characters on the screen. If you had one other NPC on screen who is speaking you could find his location and set the position of the label prior to unhiding it. However, what if you had 10 NPCs on screen who are talking? You would need 10 hidden labels just sitting around and whenever text needs to be shown iterate over the list of labels, grab the first unused label, set its position and text, then hide and release it when finished.

#3 - Similar to approach #2 but dynamically create and destroy a label for every message. This seems to make the most sense in theory but I'm not sure if creating and destroying labels frequently is an intended use of scene2d widgets.

Regardless of the approach another consideration would be the ability to move the chat bubble as an actor moves (like chat bubbles did in Ultima Online). With this in mind it seems like I should create a new label widget within the scope of my actor class where I can retain both the position of the actor and where the label should be at any given time.

From the scene2d wiki:
"Widgets can be used as simple actors in scene2d, without using tables or the rest of scene2d.ui. Widgets have a default size and can be positioned absolutely, the same as any actor."

Thoughts or recommendations? Smiley
Offline BurntPizza

« JGO Bitwise Duke »

Medals: 485
Exp: 7 years

« Reply #1 - Posted 2014-03-06 04:20:20 »

Probably your best bet is to use Labels as in #3 using either a custom Drawable / NinePatch via it's LabelStyle. Alternatively use a Button, but disable any event handling, as they are already set up to use NinePatches.
The example 'hello world' button here already looks a bit like a speech bubble.

Edit: Button idea is probably silly (it would work though) as Labels should work fine in the exact same manner, and then you also get multi-line, etc.
Pages: [1]
  ignore  |  Print  

EgonOlsen (368 views)
2018-06-10 19:43:48

EgonOlsen (374 views)
2018-06-10 19:43:44

EgonOlsen (305 views)
2018-06-10 19:43:20

DesertCoockie (549 views)
2018-05-13 18:23:11

nelsongames (874 views)
2018-04-24 18:15:36

nelsongames (857 views)
2018-04-24 18:14:32

ivj94 (1319 views)
2018-03-24 14:47:39

ivj94 (437 views)
2018-03-24 14:46:31

ivj94 (1100 views)
2018-03-24 14:43:53

Solater (449 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!