java - What code should i use to make the font-size adjust to the size of any device, in eclipse using Libgdx? -
as title says have small problem fot-size in eclipse. created font using "bmfont", , implemented in game, when tested on smaller device way big, there code can use make adjust automatically. im using libgdx ,any appreciated.
my code
@override public void show() { stage = new stage(); gdx.input.setinputprocessor(stage); atlas = new textureatlas("ui/button.pack"); skin = new skin(atlas); table = new table(skin); table.setbounds(0, 0, gdx.graphics.getwidth(), gdx.graphics.getheight()); white = new bitmapfont(gdx.files.internal("font/white.fnt"), false); black = new bitmapfont(gdx.files.internal("font/black.fnt"), false); //maakt buttons textbuttonstyle textbuttonstyle = new textbuttonstyle(); textbuttonstyle.up = skin.getdrawable("button.up"); textbuttonstyle.down = skin.getdrawable("button.down"); textbuttonstyle.pressedoffsetx = 1; textbuttonstyle.pressedoffsety = -1; textbuttonstyle.font = black; buttonexit = new textbutton("exit", textbuttonstyle); buttonexit.addlistener(new clicklistener() { @override public void clicked(inputevent event, float x, float y) { gdx.app.exit(); } }); buttonexit.pad(20); //maakt header labelstyle headingstyle = new labelstyle(white, color.white); heading = new label(papermadness.title, headingstyle); heading.setfontscale(3); table.add(heading); table.row(); table.add(buttonexit); //table.debug(); stage.addactor(table); }
you have check display's density , multiply desired font size, font same size across devices.
see link below:
https://gamedev.stackexchange.com/questions/24638/resolution-independence-in-libgdx
Comments
Post a Comment