HELP! (Slick2D)
December 18th, 2011 5:44 amSo I´m trying to pretty up my game, but I can´t get Slick2D to render fronts using the UnicodeFont class. (So I can´t use some of the fancier functions from that class)
using the Graphics Class, I manage to:
g.Drawstring(¨foo¨,x,y);
But when I do:
UnicodeFont font = new Unicodefont(new Font(fontname, Font.Plain,20);
font.draw(x,y,¨foo);
Nothing happens.
I have tried to add a font effect to UnicodeFont, but it is still not displaying
Halp, please?
EDIT: Thanks for all the help! It turns out that I have to font.loadGlyphs() at every render cycle to get my font to display.
Got some help _> lolwut?
Are you sure you want to use UnicodeFonts? AngelCode fonts are much faster, you can generate them from ttf (don’t forget to remember some symbols) with this utility
http://www.angelcode.com/products/bmfont/
But UnicodeFont should work as well. Could you paste more code? Are you drawing from within the Render routine? Is the colour properly set?
I do it like this:
Droid_Sans_16_No_Outline = new AngelCodeFont(“fonts/droid_16_sans.fnt”, “fonts/droid_16_sans_0.png”);
textFont = Droid_Sans_16_No_Outline;
textFont.drawString(xx, yy, line, colour);
Does the rest of the Slick code work properly for you? Is the OpenGL properly initialized, can you draw the Slick Images? Maybe the problem is because you use Graphics (Java2D?) instead of Slick.Images and it might not play along with lwjgl nicely.
after adding the font effect:
font.add_ascii_glyphs();
font.load_glyphs();
remember -> “select” some symbols, I meant – otherwise you’ll generate empty font
.
Yeah, I forgot to load the glyphs
So as far I as can tell, loadGlyphs() is kind of a ¨Flush¨, and the ¨Draw()¨ method doesn´t really draw? That makes sense with the behavior I´m seeing.
I´m kinda learning about Slick2D as I go along… not good, I know, but I´m getting somewhere. I should probably look into AngelFonts, seems better… but I´m moved on to the next part of the project already
Thanks for all the help! (I tried to edit my first comment but couldn´t)