1
\$\begingroup\$

In my pause dialog, the exit is working correctly, but the resume isn't, if I press resume 3 times, the third time it's going to exit.

ImageButton btnPlayOn = UIFactory.createButton(txtrPlayOn);
btnPlayOn.setSize(40, 40);
btnPlayOn.setPosition(75, 75, Align.center);
dialogP.addActor(btnPlayOn);

ImageButton btnEndGame = UIFactory.createButton(txtrEndGame);
btnEndGame.setSize(40, 40);
btnEndGame.setPosition(75, 55, Align.center);
dialogP.addActor(btnEndGame);

btnPlayOn.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                System.out.println("resuumeeeeeeee");

            }
        });

        btnEndGame.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                System.out.println("exiiiiiiiiit");

            }
        });

I think I know why, it's because both buttons have the same x so the listener is getting confused. Anyhow I don't know how to fix it.

\$\endgroup\$
1
  • \$\begingroup\$ You should not be setting widget/actor sizes like that. You should be setting the size of the cell that the actor is added to, not the actors size itself. \$\endgroup\$
    – Charanor
    Commented Mar 8, 2017 at 20:30

1 Answer 1

1
\$\begingroup\$

Looks like the buttons are overlapping so both listeners get triggered. Moving the buttons so they are not on top of each other will fix it but you should be calling event.handle() inside onclick(), that will stop the event from propagating.

Charanor's comment is only valid if you are using Tablelayout.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .