How to create your own font in AndEngine?

How do you create a custom front in the world? Almost directly from the example:

BitmapTextureAtlas font_texture = new BitmapTextureAtlas(this.getTextureManager(), 256, 256, TextureOptions.BILINEAR); mFont = FontFactory.createFromAsset(font_texture, this, "comic.ttf", 18f, true, Color.WHITE); 

But I get this error:

 The method createFromAsset(FontManager, ITexture, AssetManager, String, float, boolean, int) in the type FontFactory is not applicable for the arguments (BitmapTextureAtlas, TestGFX5Activity, String, float, boolean, Color) 

I have tried many different combinations and cannot make anything work. I want the font "comic.ttf", size 18 and white. How to do this and not get this error?

+4
source share
1 answer

Finally found the answer:

 final ITexture fontTexture = new BitmapTextureAtlas(this.getTextureManager(),256,256); mFont = FontFactory.createFromAsset(this.getFontManager(),fontTexture,this.getAssets(),"COMIC.TTF",18f,true,Color.WHITE); 

But you have to import android.graphics.Color not org.andengine.util.color.Color !!!

+9
source

All Articles