From be4e58bed776a68d5580f3ad01b3eb07dc628893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 Dec 2019 23:11:39 +0100 Subject: UiScreen : implement onDragged(...) --- test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java | 6 +++--- test/src/ch/asynk/gdx/boardgame/test/UiScreen.java | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java index deb8dca..1c1273a 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java @@ -26,9 +26,9 @@ public abstract class AbstractScreen implements Screen private static final float ZOOM_SCROLL_FACTOR = .1f; private static final float ZOOM_GESTURE_FACTOR = .01f; - protected final Vector2 dragPos = new Vector2(); - protected final Vector3 boardTouch = new Vector3(); - protected final Vector3 hudTouch = new Vector3(); + protected final Vector2 dragPos = new Vector2(0, 0); + protected final Vector3 boardTouch = new Vector3(0, 0, 0); + protected final Vector3 hudTouch = new Vector3(0, 0, 0); private ShapeRenderer shapeRenderer = null; diff --git a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java index ec06a3f..6ce119e 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java @@ -123,7 +123,6 @@ public class UiScreen extends AbstractScreen } @Override protected void onZoom(float dz) { } - @Override protected void onDragged(int dx, int dy) { } @Override protected void onTouch(int x, int y) { hudTouch.set(x, y, 0); @@ -133,6 +132,12 @@ public class UiScreen extends AbstractScreen setState(state.next()); } } + @Override protected void onDragged(int dx, int dy) + { + hudTouch.set(dragPos.x, dragPos.y, 0); + camera.unproject(hudTouch); + root.drag(hudTouch.x, hudTouch.y, -dx, dy); + } } class MyButton extends Button -- cgit v1.1-2-g2b99