A
A
Altron83372020-08-27 17:01:10
Java
Altron8337, 2020-08-27 17:01:10

Libgdx click area in non button?

Skin skin = new Skin();
        skin.add("simpleButton", new TextureRegion(atlas.findRegion("Simpl")));
        TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
        textButtonStyle.up = skin.newDrawable("simpleButton", Color.DARK_GRAY);
        textButtonStyle.down = skin.newDrawable("simpleButton", Color.DARK_GRAY);
        textButtonStyle.over = skin.newDrawable("simpleButton", Color.LIGHT_GRAY);
        textButtonStyle.font = font24;

        //кнопки
        final Group group = new Group();// группа для кнопок
        final Group group2 = new Group();
        // группа для кнопок
        final TextButton pausedButton = new TextButton("Pause", textButtonStyle);
        final TextButton exitButton = new TextButton("Exit", textButtonStyle);


 pausedButton.setPosition(0, 40);
        exitButton.setPosition(0, 0);
        group.addActor(pausedButton);  // засунем все кнопки в группу
        group.addActor(exitButton);
        group.setPosition(Gdx.graphics.getWidth() - 140, Gdx.graphics.getHeight() - 80);   // перемещаем всю группу кнопок целиком
        stage.addActor(group);
        Gdx.input.setInputProcessor(stage);


The code above displays the buttons, but when pressed, they do not work, but if you press above the button, then the button is pressed

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question