How to properly implement CheckBox in LibGDX

谁说我不能喝 提交于 2019-12-10 23:08:22

问题


I want to implement a checkbox in my game for switching volume on and off. I have this so far, but it's not working properly:

MusicOnOff.addListener( new InputListener() {
  public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
    MusicOnOff.toggle();
  }
  public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
    System.out.println("Music: " + MusicOnOff.isChecked());
    return true;
  };
});

EDIT: Ok, never mind. It's toggling with the right mouse button :O. Left is not working though


回答1:


Never used Checkbox, but I'm guessing it's supposed to automatically toggle, so if you do

MusicOnOff.toggle();

you may actually toggling it twice, giving the feeling that it never toggles.



来源:https://stackoverflow.com/questions/19350350/how-to-properly-implement-checkbox-in-libgdx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!