Question

I am using custom font in andengine and when the user click that ui I need to change the color of my ui.Here is my code.

Text exit=new Text(250, 390, this.mPlokFont, "Exit");
exit.setColor(255,0, 0, 255);  
scene.attachChild(exit); 

but it doesn't work. My font :

mPlokFont = FontFactory.createFromAsset(this.mPlokFontTexture, this, "Plok.ttf", 16, true, Color.WHITE);

Thanks in advance.

Was it helpful?

Solution

Try to use ChangeableText instead of Text

OTHER TIPS

I'm pretty sure you are facing this issue because you are using premultiplied alpha in the font texture. Try this

mFontTexture = new BitmapTextureAtlas(256, 256, TextureOptions.BILINEAR);
mUIFont = new Font(m_FontTexture, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32, true, Color.WHITE);

and it should work. AFAIK, premultiplied alpha means the RGB values in the texture are already multiplied by an alpha value, so calling .setAlpha() will not change anything (it will not be applied.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top