There is an application, a snake, controlled from the keyboard, with the keys up-down-right-left. I would like to draw 4 buttons and link them to these keys. So with tachksrina could play.

I saw a topic here. How to draw a Button in libgdx?

However, the code that is there is inserted into the Show method. I do not have this, there is a Create method, when inserted into it, Assets in Assets.manager.get underlines in red.

I looked on the Internet - there is generally code to create a joystick on the screen with 150 lines.

Is there really no easy way to draw a button, like in a simple android, something like

ImageButton ibutton = new ImageButton("0, 0, @assets/vpravo.png, keys.down"); 

    1 answer 1

    You can use json. Here is a small sample code:

     private Stage stage; private Skin skin; private Table table = new Table(); stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); Gdx.input.setInputProcessor(stage); skin = new Skin(Gdx.files.internal("skin/uiskin.json")); final TextButton playTextButton=new TextButton("Play",skin); final TextButton exitTextButton=new TextButton("Exit",skin); final TextButton optionsTextButton = new TextButton("Options",skin); table.setFillParent(true); table.add(playTextButton).size(100,50); table.add(optionsTextButton).size(100,50); table.add(exitTextButton).size(100,50); stage.addActor(table);