所以我有一个像这样的 sceneu2.ui 表:
+--------------------------------------+
|+---------+ +------------+ +---------+|
|| Table 1 | | ScrollPane | | Table 2 ||
|+---------+ +------------+ +---------+|
+--------------------------------------+
| My Actor |
+--------------------------------------+
里面scrollpane
是另一个table
。外壳也是一个table
。Table 1
,Table 2
并且table
里面scrollpane
有相同的行数。
My Actor
是简单的图像按钮演员,也支持鼠标悬停。
问题是,My Actor
一开始没有出现(但它的边界存在——通过表调试行检查)但是当我scrollpane
(用鼠标)滚动一些东西时,它出现了 2 秒钟,然后开始消失。(预期的结果应该是一直出现)
我究竟做错了什么?
My Actor
班级:
public class GameButton extends Actor {
public static abstract class Listener {
public abstract void onClick();
}
final Texture[] current;
final Listener listener;
boolean disabled;
int state = 0;
public GameButton(Texture[] current, final Listener listener) {
this.current = current;
setWidth(current[0].getWidth());
setHeight(current[0].getHeight());
this.listener = listener;
disabled = false;
this.addListener(new InputListener() {
boolean just_up = false;
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
state = 2;
return true;
}
@Override
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
state = 0;
if (hit(x, y, false) != null) {
just_up = true;
state = 1;
if (listener != null && !disabled)
listener.onClick();
}
}
@Override
public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) {
if (state == 0)
state = 1;
}
@Override
public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) {
if (!just_up)
state = 0;
just_up = false;
}
});
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
@Override
public void draw(SpriteBatch batch, float _) {
super.draw(batch, _);
batch.draw(current[disabled ? 0 : state], getX(), getY(), getWidth(), getHeight());
}
}
用于将其添加到表中的代码:
btnBack = new GameButton(Assets.btnBack, 0, 0, new GameButton.Listener() {
@Override
public void onClick() {
/* removed */
}
});
add(btnBack).colspan(3).right().bottom().height(128);