0
votes

I'm using this project to learn how to make a libgdx game. I tried following tutorials online to setup a menu like this but it force closes when I click on the play button. The logcat says that there is an error where it says game.setScreen(new SelectScreen());

    MenuButton localMenuButton1 = new MenuButton(this, "", localTextButtonStyle1);
        localMenuButton1.addListener(new ClickListener()
        {
            @Override
            public void clicked(InputEvent paramAnonymousInputEvent, float paramAnonymousFloat1, float paramAnonymousFloat2)
            {
            game.setScreen(new SelectScreen(game)); 
            }
        });

I've searched all over the net trying to find a solution but can't find anything. Any help would be appreciated.

1
Add the logcat exception stacktrace please. - noone
The logcat did output that there is "an error" ? - donfuxx

1 Answers

0
votes

Not sure what "paramAnonymousInputEvent" is in your scenario, but i use the below code for all my buttons, no problems with doing it this way as far as i know

        final TextButton btOptions = new TextButton("Options", skin, "default");

    btOptions.addListener(new ClickListener(){
        @Override 
        public void clicked(InputEvent event, float x, float y){
            myGame.setScreen(new MyOptionsScreen(myGame));

        }
    });