Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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 831 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
Online BurntPizza

« JGO Bitwise Duke »


Medals: 291
Exp: 5 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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (10 views)
2014-12-23 03:34:11

rwatson462 (38 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org 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‑gaming.org
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!