java - How to display many text input fields in libgdx at a random position on the main window? -
i want display many text input fields libgdx (like example name, surname, email) user has input info. i've tried following https://github.com/libgdx/libgdx/wiki/simple-text-input it's not best option in case both because want included in main window instead of opening new little 1 , because displays 1 text input field. want able make fields appear @ random position on main window.
you can use scene2d widget requirement, create label , textfield , add stage. can use table arrangement of actors.
public class splash extends game { private stage stage; @override public void create() { extendviewport extendviewport=new extendviewport(700,1200,new orthographiccamera()); stage=new stage(extendviewport); skin skin=new skin(gdx.files.internal("skin/uiskin.json")); skin.get("font-label", bitmapfont.class).getregion().gettexture().setfilter(texture.texturefilter.linear, texture.texturefilter.linear); table table=new table(); table.defaults().pad(10); table.setfillparent(true); label username=new label("user id : ",skin); textfield usernamefield=new textfield("",skin); label name =new label("name : ",skin); textfield namefield=new textfield("",skin); label email=new label("email : ",skin); textfield emailfield=new textfield("",skin); table.add(username); table.add(usernamefield).width(300); table.row(); table.add(name).left(); table.add(namefield).width(300); table.row(); table.add(email).left(); table.add(emailfield).width(300); stage.addactor(table); gdx.input.setinputprocessor(stage); } @override public void render() { super.render(); gdx.gl.glclearcolor(0,1,1,1); gdx.gl.glclear(gl20.gl_color_buffer_bit); stage.draw(); stage.act(); } @override public void resize(int width, int height) { super.resize(width,height); stage.getviewport().update(width,height); } @override public void dispose() { stage.dispose(); }
output looks :
Comments
Post a Comment