Android Question libGDX: using fonts giving null pointer error

andymc

Well-Known Member
Licensed User
Longtime User
I'm trying to use fonts in a game I'm making but I'm getting a null pointer exception in my main batch loop.

I setup the font with:
B4X:
Dim bitmapfont As lgBitmapFont
then in lg_create:
B4X:
    bitmapfont.Initialize
    bitmapfont.SetColorRGBA(0, 0, 0, 1) 'Blue
in lg_render I then call:
B4X:
bitmapfont.Draw(Batch,"Score",50%x,50%y)
 

andymc

Well-Known Member
Licensed User
Longtime User
Okay, I've figured it out. I think the Lib does not include a default bitmap font file. So I generated one using this:
http://www.angelcode.com/products/bmfont/
And then saved the fnt file into my files folder for my project. I then initialised the font in B4A using the line:
B4X:
bitmapfont.Initialize2(lGdx.Files.internal("bmfont.fnt"))

And this has worked
 
Upvote 0
Top