我在游戏中使用了 ImageButton ,我想让它显示被触摸或按下。 libgdx 框架是我的新手。
TextureRegion btLeft = new TextureRegion(new Texture("NUMBEROFF.png"));
Drawable drawableLeft = new TextureRegionDrawable(new TextureRegion(btLeft));
buttonLeft = new ImageButton(drawableLeft);
答案 0 :(得分:0)
ImageButton有不同的构造函数,可让您在按钮处于不同状态(上,下和选中)时添加多个Drawable。但是我更喜欢使用ImageButtonStyle来做到这一点。
ImageButtonStyle style = new ImageButtonStyle();
style.imageUp = ...your drawable for up (normal) state
style.imageChecked = ...your drawable for checked state
style.imageDown = ...your drawable for down (pressed) state
ImageButton button = new ImageButton(style);