opengl - Cannot draw TextButton or Button in LibGDX for desktop -
i trying make menu in libgdx. cannot button or textbutton drawn in screen. tried using test skin. tried use table. tried use button , textbutton.
the image fine because can appears while drawing using spritebatch , font works well.
this part of code.
public class menu implements screen { private stage stage; private skin skin; private textbutton textbutton; private game mygame; private bitmapfont font; private textureatlas atlas; private spritebatch batch; private textureregion test; public splashscreen(game g){ mygame = g; } @override public void show() { batch = new spritebatch(); stage = new stage(); stage.clear(); atlas = new textureatlas("buttons/bot.pack"); skin = new skin(atlas); font = new bitmapfont(gdx.files.internal("fonts/arialfnt.fnt"),false); textbuttonstyle buttonstyle = new textbuttonstyle(); buttonstyle.up = skin.getdrawable("button.up"); buttonstyle.over = skin.getdrawable("button.over"); buttonstyle.down = skin.getdrawable("button.down"); buttonstyle.font = font; textbutton = new textbutton("click here", buttonstyle); textbutton.setposition(200, 300); textbutton.setheight(300); textbutton.setwidth(100); test = atlas.findregion("button.up"); //testing atlas stage.addactor(textbutton); } @override public void render(float delta) { gdx.gl.glclearcolor(0, 0, 0, 1); gdx.gl.glclear(gl30.gl_color_buffer_bit); stage.act(delta); stage.draw(); //does not work batch.begin(); batch.draw(test, 300, 300); //it works font.draw(batch, "bla bla!", 50, 500); //it works batch.end(); } }
do have suggestion make work? can because of gl3.0?
i don't have enough rep comment best guess need set stage viewport. can't @ code or libgdx source yet try have when home. stage has it's own camera i'm not sure how that's handled in default constructor. check later.
Comments
Post a Comment