Adding text on text

Anything libgdx related goes here!

Adding text on text

Postby mmtbb » Sun Jan 02, 2011 2:00 am

Text caching has been very helpful. Could you add a function for adding text to the cache at different locations?
Something like this example:

textCache.setColor(Color.WHITE);
textCache.setText("Hello",10,20);

textCache.setColor(Color.RED);
textCache.addText("Hello",13,23);

That way I could make text overlap, make text different colors in the same cache, and make other cool effects without using another cache.

Thanks
mmtbb
 
Posts: 135
Joined: Thu Nov 11, 2010 6:56 pm

Re: Adding text on text

Postby NateS » Sun Jan 02, 2011 4:52 am

We could change the set*Text methods to add*Text and add a clear method, however, this would make the setBounds method make less sense. I suppose it could compute the bounds of all the text that has been added.

BitmapFontCache only caches the arguments to the set*Text methods. It doesn't cache the color, which is the tint color to apply when the text is drawn. Currently, if you want multiple colors, you have to use multiple caches.

The only downside to using multiple caches is that you must manage them yourself. There isn't a performance penalty. The BitmapFontCache class itself could do this management solely to simplify your code, but I lean towards keeping the core class simple and asking you to implement the extra functionality in your code. Just keep an Array of BitmapFontCache instances and call draw on each one.
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest