summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-22 10:39:15 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-22 10:49:01 +0100
commit7733c7aacb5453dee49768e246282ee1ff7b46cc (patch)
tree2b0b22747cc4c4980d2f163ce2fb93b1fbbca550
parentf03589a9898592a5ce9f1192665a4030a148eddc (diff)
downloadRustAndDust-7733c7aacb5453dee49768e246282ee1ff7b46cc.zip
RustAndDust-7733c7aacb5453dee49768e246282ee1ff7b46cc.tar.gz
MenuScreen: add boolean touchDragged(int, int, int)
-rw-r--r--core/src/ch/asynk/rustanddust/screens/MenuScreen.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/screens/MenuScreen.java b/core/src/ch/asynk/rustanddust/screens/MenuScreen.java
index fb09ad8..27a78c8 100644
--- a/core/src/ch/asynk/rustanddust/screens/MenuScreen.java
+++ b/core/src/ch/asynk/rustanddust/screens/MenuScreen.java
@@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.Sprite;
+import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.Interpolation;
@@ -51,6 +52,7 @@ public class MenuScreen implements Screen
private final MenuCamera camera;
private final SpriteBatch batch;
+ private Vector2 dragPos = new Vector2();
private Vector3 touch = new Vector3();
public MenuScreen(final RustAndDust game)
@@ -81,8 +83,20 @@ public class MenuScreen implements Screen
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
+ public boolean touchDragged(int x, int y, int pointer)
+ {
+ int dx = (int) (dragPos.x - x);
+ int dy = (int) (dragPos.y - y);
+ dragPos.set(x, y);
+ camera.uiUnproject(x, y, touch);
+ ctrl.drag(touch.x, touch.y, -dx, dy);
+ return true;
+ }
+
+ @Override
public boolean touchDown(int x, int y, int pointer, int button)
{
+ dragPos.set(x, y);
camera.uiUnproject(x, y, touch);
if (ctrl.touch(touch.x, touch.y))
startLoading();