Reputation: 71
I am trying to create a score text for my game. When i run the code i get no errors but i don't see any text. Here's the code for initizaling the text:
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("Gameplay/font.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 30;
parameter.characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.!'()>?: ";
font = generator.generateFont(parameter);
generator.dispose();
font.setColor(Color.WHITE); And here is the code for rendering the text:
Gdx.gl20.glClearColor(0F, 0F, 0F, 1F);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
sb.begin();
font.draw(sb, "test", 0, 0);
sb.end();
I don't see any text what so ever, thanks for any help! :)
Upvotes: 0
Views: 186
Reputation: 3146
BitmapFonts in libgdx are drawn from the top down, so the top of your text is at y=0 and hence the rest of your text is being displayed underneath the visible screen.
As a test, try changing y to something in the middle of the screen.
There may be other issues too, so if the text still doesn't appear I suggest you provide a bit more code so we can help further.
Upvotes: 0