BitmapText with two or different Colours

Hi,
is there a possibility or method where i can easily set the colour of the first word of the String of my BitmapText to, for example, green, let the second word white and set the last word (there are 3 words) to red without losing the right order of all my words?
Hope u can help me pls :slight_smile:

Have you read through the javadocs or looked at the code for BitmapText?

I remember there being a way to do this… but can’t remember how for the life of me.

http://hub.jmonkeyengine.org/javadoc/com/jme3/font/BitmapText.html

https://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/font/BitmapText.java?r=7859

There is a way to embed color codes right in the text. It’s not well documented, I guess, except in the source code. I guess the only place it is really mentioned is in the javadoc for a class that doesn’t get javadoc’ed. :-/

https://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/font/ColorTags.java?r=7859

There is also this method:
http://hub.jmonkeyengine.org/javadoc/com/jme3/font/BitmapText.html#setColor(int,%20int,%20com.jme3.math.ColorRGBA)

1 Like

What I do in situations like this is always make my Fonts white. Then I can change the colors any way I want when I put it to the screen. I never use BitMapped files that have fonts that are in color. I use white for everything and I let the Code change the color.

If this isn’t what you mean, then please ignore my reply.

@TorakTu said: What I do in situations like this is always make my Fonts white. Then I can change the colors any way I want when I put it to the screen. I never use BitMapped files that have fonts that are in color. I use white for everything and I let the Code change the color.

If this isn’t what you mean, then please ignore my reply.

It isn’t. He’s referring to a specific class in JME that is already doing what you’ve described doing manually.

Oh I see, ok thanks for the heads up.

Thank you that Method worked fine.