Tuesday, May 12, 2015

fonts - Why is my text is too large even when scaled to .05f in libGDX?


I'm trying to scale down my fonts as my game objects are also small.


I'd like to scale them down the same way as my sprites. However, if I scale them below .05, the font disappears!


My attempt at small, smooth text above an orange grid:


oversized text



The code:


private void initTestObjects() {
textures = new TextureAtlas(Gdx.files.internal("data/atlas.atlas"));//i am not using atlas params(for now -.-, I cut from texture..)

//text texture and bitmapfont
texturesText = new Texture(Gdx.files.internal("data/fonts_0.png"), true);
texturesText.setFilter(Texture.TextureFilter.MipMapLinearNearest, Texture.TextureFilter.Linear);
bitmapFonts = new BitmapFont(Gdx.files.internal("data/fonts.fnt"), new TextureRegion(texturesText), false);
bitmapFonts.setScale(.1f);


//grid texture and sprite
TextureAtlas.AtlasRegion grid = textures.findRegion("grid");
gridSprite = new Sprite(grid);
gridSprite.setSize(SIZE, SIZE);//4x4
gridSprite.setOrigin(gridSprite.getWidth() / 2, gridSprite.getHeight() / 2);
gridSprite.setPosition(0 - gridSprite.getOriginX(), 0 - gridSprite.getOriginY());

//players' textures
o = textures.findRegion("o");
x = textures.findRegion("x");


line = textures.findRegion("line");
}

What am I doing wrong?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...