Home | Rules and Guide | Sign In/Create Account | Write a Post | Reddit | #LD48 | #ludumdare on irc.afternet.org (Info)

Ludum Dare 30 — August 22nd-25th 2014 — Theme: Connected Worlds
  • Judging Ends: in 13 days, 10 hours, 54 minutes, 26 seconds
  • [ Real World Gatherings | Ludum Deals | Warmup Weekend (Games) | MiniLD #53 | Wallpaper (1) (2) (3) | Mailing List ]

    [ Play+Rate | Edit | View All Games | My Game ]


    HELP! (Slick2D)

    Posted by (twitter: @caranha)
    December 18th, 2011 5:44 am

    So 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.

    Tags: , ,

    5 Responses to “HELP! (Slick2D)”

    1. caranha says:

      Got some help _> lolwut?

    2. kibertoad says:

      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.

    3. Jarek Radosz says:

      after adding the font effect:

      font.add_ascii_glyphs();
      font.load_glyphs();

    4. kibertoad says:

      remember -> “select” some symbols, I meant – otherwise you’ll generate empty font :).

    5. caranha says:

      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)

    Leave a Reply

    You must be logged in to post a comment.


    All posts, images, and comments are owned by their creators.

    [cache: storing page]