Button ClickListener is not working in LibGDX game

后端 未结 2 857
时光取名叫无心
时光取名叫无心 2020-12-18 19:31

I am developing an Android game using LibGDX. There are 4 buttons in a menu screen, but the ClickListener of these buttons is not working.

//         


        
相关标签:
2条回答
  • 2020-12-18 19:40

    Instead of "click method" now it's "clicked method" (I think!), just in case someone faces the same problem I was facing when found this question:

    startGameButton.addListener( new ClickListener() {              
        @Override
        public void clicked(InputEvent event, float x, float y) {
            game.setScreen( new GameScreen(game) );
        };
    });
    
    0 讨论(0)
  • 2020-12-18 19:42

    You have to add the button to the stage and call

    Gdx.input.setInputProcessor(stage);
    
    0 讨论(0)
提交回复
热议问题