summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-17 11:09:31 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-17 11:09:31 +0200
commitaadc15ec9504f9cbebf7e4babe96d2ee10b7d3d4 (patch)
tree47b8fd48b9f9b139627481f397f6abc1aa16f28e /core/src
parent0c84007ab76062e7289ac9122ef3a02de9c9490e (diff)
downloadRustAndDust-aadc15ec9504f9cbebf7e4babe96d2ee10b7d3d4.zip
RustAndDust-aadc15ec9504f9cbebf7e4babe96d2ee10b7d3d4.tar.gz
GameScreen: be sure that touchUp will never be triggered if touchDown is blocked
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameScreen.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java
index c4dd19b..c9cf00e 100644
--- a/core/src/ch/asynk/tankontank/screens/GameScreen.java
+++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java
@@ -31,7 +31,7 @@ public class GameScreen implements Screen
{
private static final boolean DEBUG = false;
- private static final float INPUT_DELAY = 0.3f;
+ private static final float INPUT_DELAY = 0.1f;
private static final float ZOOM_IN_MAX = 0.2f;
private static final float ZOOM_GESTURE_FACTOR = .01f;
private static final float ZOOM_SCROLL_FACTOR = .1f;
@@ -52,6 +52,7 @@ public class GameScreen implements Screen
private final TankOnTank game;
private Ctrl ctrl;
+ private boolean blocked;
private float inputDelay = 0f;
private Vector2 dragPos = new Vector2();
private Vector3 touchPos = new Vector3();
@@ -95,6 +96,7 @@ public class GameScreen implements Screen
cam.zoom -= ZOOM_GESTURE_FACTOR;
cam.zoom = MathUtils.clamp(cam.zoom, ZOOM_IN_MAX, maxZoomOut);
clampCameraPos();
+ blocked = true;
inputDelay = INPUT_DELAY;
return true;
}
@@ -108,6 +110,7 @@ public class GameScreen implements Screen
dragPos.set(x, y);
cam.translate(-deltaX, -deltaY, 0);
clampCameraPos();
+ blocked = true;
inputDelay = INPUT_DELAY;
return true;
}
@@ -115,6 +118,7 @@ public class GameScreen implements Screen
public boolean touchDown(int x, int y, int pointer, int button)
{
if (inputDelay > 0f) return true;
+ blocked = false;
if (button == Input.Buttons.LEFT) {
dragPos.set(x, y);
if (ctrl.mayProcessTouch()) {
@@ -130,7 +134,7 @@ public class GameScreen implements Screen
@Override
public boolean touchUp(int x, int y, int pointer, int button)
{
- if (inputDelay > 0f) return true;
+ if (blocked) return true;
if (button == Input.Buttons.LEFT) {
if (ctrl.mayProcessTouch()) {
unprojectToHud(x, y, touchPos);
@@ -140,6 +144,7 @@ public class GameScreen implements Screen
}
}
}
+ blocked = true;
inputDelay = INPUT_DELAY;
return true;
}
@@ -149,6 +154,7 @@ public class GameScreen implements Screen
cam.zoom += amount * ZOOM_SCROLL_FACTOR;
cam.zoom = MathUtils.clamp(cam.zoom, ZOOM_IN_MAX, maxZoomOut);
clampCameraPos();
+ blocked = true;
inputDelay = INPUT_DELAY;
return true;
}