1

Image Button выводится нормально, но при нажатии ничего не происходит.

ImageButton.ImageButtonStyle ImageButtonRight = new ImageButton.ImageButtonStyle();
ImageButtonRight.up = skin.getDrawable("button_right");
ImageButtonRight.down = skin.getDrawable("button_right");

ImageButton buttonRight = new ImageButton(ImageButtonRight);
buttonRight.setSize(200, 200);
buttonRight.setPosition(10, 10);

buttonRight.addListener(new ClickListener() {
    @Override
    public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
        return true;
    }
    @Override
    public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
        game.setScreen(new GameOverScreen(game));
        dispose();
    }
});

stage.addActor(buttonRight);

1 ответ 1

2

Добавьте эту строчку

Gdx.input.setInputProcessor(stage);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.