summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-16 12:26:08 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-16 12:26:08 +0200
commitf986dd3fe0c0cb1e73e47fab2deb5a0929f185a9 (patch)
tree2ebbba3c2ea4d8657a98ebd1fd41c11dcd3a1ebc /core/src
parentc47b62c26608f04139488354440d1c9167b779a7 (diff)
downloadRustAndDust-f986dd3fe0c0cb1e73e47fab2deb5a0929f185a9.zip
RustAndDust-f986dd3fe0c0cb1e73e47fab2deb5a0929f185a9.tar.gz
GameScreen: add inputDelay after touchUp, drag, scroll, zoom
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameScreen.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java
index bf965ed..067a898 100644
--- a/core/src/ch/asynk/tankontank/screens/GameScreen.java
+++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java
@@ -31,6 +31,7 @@ public class GameScreen implements Screen
{
private static final boolean DEBUG = false;
+ private static final float INPUT_DELAY = 0.5f;
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;
@@ -51,6 +52,7 @@ public class GameScreen implements Screen
private final TankOnTank game;
private Ctrl ctrl;
+ private float inputDelay = 0f;
private Vector2 dragPos = new Vector2();
private Vector3 touchPos = new Vector3();
private Vector2 screenToWorld = new Vector2();
@@ -93,6 +95,7 @@ public class GameScreen implements Screen
cam.zoom -= ZOOM_GESTURE_FACTOR;
cam.zoom = MathUtils.clamp(cam.zoom, ZOOM_IN_MAX, maxZoomOut);
clampCameraPos();
+ inputDelay = INPUT_DELAY;
return true;
}
}));
@@ -105,11 +108,13 @@ public class GameScreen implements Screen
dragPos.set(x, y);
cam.translate(-deltaX, -deltaY, 0);
clampCameraPos();
+ inputDelay = INPUT_DELAY;
return true;
}
@Override
public boolean touchDown(int x, int y, int pointer, int button)
{
+ if (inputDelay > 0f) return true;
if (button == Input.Buttons.LEFT) {
dragPos.set(x, y);
if (ctrl.mayProcessTouch()) {
@@ -120,12 +125,12 @@ public class GameScreen implements Screen
}
}
}
-
return true;
}
@Override
public boolean touchUp(int x, int y, int pointer, int button)
{
+ if (inputDelay > 0f) return true;
if (button == Input.Buttons.LEFT) {
if (ctrl.mayProcessTouch()) {
unprojectToHud(x, y, touchPos);
@@ -135,6 +140,7 @@ public class GameScreen implements Screen
}
}
}
+ inputDelay = INPUT_DELAY;
return true;
}
@Override
@@ -143,6 +149,7 @@ public class GameScreen implements Screen
cam.zoom += amount * ZOOM_SCROLL_FACTOR;
cam.zoom = MathUtils.clamp(cam.zoom, ZOOM_IN_MAX, maxZoomOut);
clampCameraPos();
+ inputDelay = INPUT_DELAY;
return true;
}
});
@@ -175,6 +182,8 @@ public class GameScreen implements Screen
@Override
public void render(float delta)
{
+ if (inputDelay > 0f)
+ inputDelay -= delta;
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);