如何禁用libgdx中的按钮?

如何禁用libgdx中的按钮?,libgdx,imagebutton,Libgdx,Imagebutton,我有一个图像按钮,我想在程序启动时被禁用,在特定条件下,需要启用它 这是我的密码 publicscreen(){//constructor 图像按钮提示; ImageButton.ImageButtonStyle HintStyle=新建ImageButton.ImageButtonStyle(); hintsstyle.up=skin.getDrawable(“newrightbut”); hintsstyle.down=skin.getDrawable(“newrightbut”); hin

我有一个图像按钮,我想在程序启动时被禁用,在特定条件下,需要启用它

这是我的密码

publicscreen(){//constructor
图像按钮提示;
ImageButton.ImageButtonStyle HintStyle=新建ImageButton.ImageButtonStyle();
hintsstyle.up=skin.getDrawable(“newrightbut”);
hintsstyle.down=skin.getDrawable(“newrightbut”);
hintsstyle.pressedOffsetX=1;
提示=新图像按钮(hintsstyle);
提示:设置位置(650,35);
提示:设置高度(70);
提示:设置宽度(70);
舞台演员(提示);
提示。可设置触摸(可触摸。禁用);
}
公共无效更新(){
提示.setTouchable(Touchable.enabled);
}

但是,当程序启动时,按钮并没有被禁用,我甚至用button.setDisabled(true)方法进行了测试。它也不起作用。知道为什么吗?任何帮助都会很好!!谢谢

这一期已经发行5个月了,但我还是尽力回答

ImageButton
提示
在构造函数中声明(因此其范围仅限于构造函数)

如果您在类的其他地方也声明了编译错误,那么从构造函数外部的方法调用编译错误就不会出现


结论:您必须在应用程序中的其他地方声明它,并且默认情况下,它是启用的。

共享您的变量声明代码。