问题
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