11

I saw this post Multi-colored text in libgdx but it's not useful specially in new API.

For example: I want to color "libGDX" text like this: enter image description here

BitmapFont font = new BitmapFont(Gdx.files.internal("fonts/CarterOne.fnt"));
LabelStyle style = new LabelStyle(font, null);
Label label = new Label("libGDX", style);
stage.addActor(label);

How can I do this ?

Community
  • 1
  • 1
iibrahimbakr
  • 1,116
  • 1
  • 13
  • 32

1 Answers1

15

You can do this easily with the color markup language that Label supports as well.

Make sure to read that article completely, as there are a few little obstacles involved to get it working.

noone
  • 19,520
  • 5
  • 61
  • 76
  • 1
    I didn't found any obstacles :) that's very easy `font.getData().markupEnabled = true; LabelStyle style = new LabelStyle(font, null); Label label = new Label("[#ff0000]l[#30ff00]i[#1e00ff]b[#fff600]G[#ff00ae]D[][#ff9000]X", style);` THANKS A LOT @noone – iibrahimbakr Nov 02 '15 at 02:40