ボタンとしてステージを持つアクターを使用しています。touchDown/touchUp イベントがアクター上で問題なく発生したことを検出できますが、ユーザーがアクターをタップしてから指をアクターからドラッグすると、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");
}
});