如何在LibGDX中正确实现CheckBox [英] How to properly implement CheckBox in LibGDX

查看:90
本文介绍了如何在LibGDX中正确实现CheckBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的游戏中实现一个复选框,用于打开和关闭音量.到目前为止,我已经知道了,但是它不能正常工作:

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;
  };
});

好的,没关系.使用鼠标右键:O进行切换.左虽然不起作用

推荐答案

从未使用过Checkbox,但是我猜它应该自动切换,所以如果您这样做

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.

这篇关于如何在LibGDX中正确实现CheckBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆