When you generate a font you get a BitmapFont
object.
You can set it's color like this:
BitmapFont someFont = freeTypeGenerator.getFont(); // or something like that
someFont.setColor(Color.RED);
Also, it's better to change widgets colors, not fonts, for example if you have a Label with the font created above, you can change label's color:
label.setColor(Color.RED);
For coordinates read about viewports here: https://github.com/libgdx/libgdx/wiki/Viewports
How to create a color?
Colors in our world contain 4 values - R, G, B and A which means red, green, blue and alpha channel.
RGB are for colors and A is for transparency.
If you want your color to be RED, you set RED to 1, BLUE to 0 and GREEN to 0
If you want your color to be HALF RED and HALF BLUE you set RED to 0.5f, BLUE to 0.5f and GREEN to 0f.
If you look into the LibGDX
source, Color constructor takes 4 parameters (R,G,B and A) and these values must be in range 0-1f
. It means that if you set your color to new Color(0,0,0,1)
- it will be a black color. If you set it to new Color(1,1,1,1)
- you'll get a white color. As you can see, maximum value for R, G, B and A is 1. So how to create Colors from RGB values like 77,55,133?
You just divide it by 255f
and you'll get your R, G and B values.
Correct way:
Color color = new Color(255f/255f, 183f/255f, 77f/255f, 255f/255f);