diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-05-31 12:14:58 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-05-31 12:14:58 +0200 |
commit | e21494ec9d42706ab4af5c30c6dc685841d00988 (patch) | |
tree | f5e33da0854213eda21dcc84fcc71aa25e61675e /test | |
parent | 05e7f467bd6c062a4b658d3a60bbadee804c7efc (diff) | |
download | gdx-boardgame-e21494ec9d42706ab4af5c30c6dc685841d00988.zip gdx-boardgame-e21494ec9d42706ab4af5c30c6dc685841d00988.tar.gz |
AbstractScreen : support touchUp(…)
Diffstat (limited to 'test')
5 files changed, 26 insertions, 12 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java index b8c4acb..b3963fb 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java @@ -135,7 +135,7 @@ public abstract class AbstractScreen implements Screen paused = false; } - protected abstract void onTouch(int x, int y); + protected abstract void onTouch(int x, int y, boolean down); protected abstract void onZoom(float dz); protected abstract void onDragged(int dx, int dy); private InputMultiplexer getMultiplexer() @@ -147,15 +147,27 @@ public abstract class AbstractScreen implements Screen onZoom(amount * ZOOM_SCROLL_FACTOR); return true; } + + @Override public boolean touchUp(int x, int y, int pointer, int button) + { + if (inputBlocked) return true; + if (button == Input.Buttons.LEFT) { + dragPos.set(x, y); + onTouch(x, y, false); + } + return true; + } + @Override public boolean touchDown(int x, int y, int pointer, int button) { if (inputBlocked) return true; if (button == Input.Buttons.LEFT) { dragPos.set(x, y); - onTouch(x, y); + onTouch(x, y, true); } return true; } + @Override public boolean touchDragged(int x, int y, int pointer) { int dx = (int) (x - dragPos.x); diff --git a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java index ecd9c86..fc6fc30 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java @@ -222,5 +222,5 @@ public class AnimationsScreen extends AbstractScreen @Override protected void onZoom(float dz) { } @Override protected void onDragged(int dx, int dy) { } - @Override protected void onTouch(int x, int y) { } + @Override protected void onTouch(int x, int y, boolean down) { } } diff --git a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java index 8461d64..2c568cb 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java @@ -269,14 +269,16 @@ public class BoardScreen extends AbstractScreen cam.translate(dx, dy); } - @Override protected void onTouch(int x, int y) + @Override protected void onTouch(int x, int y, boolean down) { - cam.unproject(x, y, boardTouch); - cam.unprojectHud(x, y, hudTouch); - if (btn.touch(hudTouch.x, hudTouch.y) != null) { - setState(state.next()); - } else { - board.touch(boardTouch.x, boardTouch.y); + if (down) { + cam.unproject(x, y, boardTouch); + cam.unprojectHud(x, y, hudTouch); + if (btn.touch(hudTouch.x, hudTouch.y) != null) { + setState(state.next()); + } else { + board.touch(boardTouch.x, boardTouch.y); + } } } diff --git a/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java b/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java index b0a312a..fafb9e0 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java @@ -69,7 +69,7 @@ public class MenuScreen extends AbstractScreen @Override protected void onZoom(float dz) { } @Override protected void onDragged(int dx, int dy) { } - @Override protected void onTouch(int x, int y) + @Override protected void onTouch(int x, int y, boolean down) { hudTouch.set(x, y, 0); camera.unproject(hudTouch); diff --git a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java index b490b05..4120fac 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java @@ -200,7 +200,7 @@ public class UiScreen extends AbstractScreen } @Override protected void onZoom(float dz) { } - @Override protected void onTouch(int x, int y) + @Override protected void onTouch(int x, int y, boolean down) { hudTouch.set(x, y, 0); camera.unproject(hudTouch); |