我正在使用舞台上的演员作为按钮。我可以很好地检测到触摸/释放事件发生在演员上,但是当用户点击演员并然后拖动手指离开演员时,touchUp事件从未触发。我尝试使用exit事件,但它从未触发。在我的程序中,touchUp/touchDown事件确定移动以及取决于按钮是否被按下而改变的按钮颜色。所以我只能得到一个永久性的“被按下”的按钮,直到再次点击下/释放。
以下是我的代码示例:
以下是我的代码示例:
stage.addListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
Actor actor = stage.hit(x, y, true);
if (actor != null){
System.out.println("touchDown: " + actor.getName().toString());
}
return true;
}
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
Actor actor = stage.hit(x, y, true);
if (actor != null){
System.out.println("touchUp: " + actor.getName().toString());
}
}
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor){
System.out.println("exit");
}
});
Stage.addListener()
。也许这是一个错误,在比你所使用的版本更新的版本中已经修复了。 - kichiktouchDragged()
可能有帮助。 - kichik