summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-30 16:34:14 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-30 16:34:14 +0200
commit5add1674ee031eaada9d19d07dde5efbd071b4f0 (patch)
treeee5ebc0f1a34fb76175e4026734027c0152508e3
parent9507c5fcce6f5b41b167ce200692111b00457600 (diff)
downloadRustAndDust-5add1674ee031eaada9d19d07dde5efbd071b4f0.zip
RustAndDust-5add1674ee031eaada9d19d07dde5efbd071b4f0.tar.gz
GameScreen: fix cam.unproject() after resize
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameScreen.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java
index 6169509..2669e70 100644
--- a/core/src/ch/asynk/tankontank/screens/GameScreen.java
+++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java
@@ -144,7 +144,7 @@ public class GameScreen implements Screen
float deltaY = ((dragPos.y - y) * cam.zoom * screenToViewport.y);
dragPos.set(x, y);
if (map.drag(deltaX, deltaY)) {
- cam.unproject(touchPos.set(x, y, 0));
+ unproject(x, y, touchPos);
map.getHexAt(cell, touchPos.x, touchPos.y);
} else {
cam.translate(-deltaX, -deltaY, 0);
@@ -157,16 +157,17 @@ public class GameScreen implements Screen
{
if (button == Input.Buttons.LEFT) {
dragPos.set(x, y);
- cam.unproject(touchPos.set(x, y, 0));
+ unproject(x, y, touchPos);
map.touchDown(touchPos.x, touchPos.y);
}
+
return true;
}
@Override
public boolean touchUp(int x, int y, int pointer, int button)
{
if (button == Input.Buttons.LEFT) {
- cam.unproject(touchPos.set(x, y, 0));
+ unproject(x, y, touchPos);
map.touchUp(touchPos.x, touchPos.y);
}
return true;
@@ -184,6 +185,11 @@ public class GameScreen implements Screen
return multiplexer;
}
+ private void unproject(int x, int y, Vector3 v)
+ {
+ cam.unproject(v.set(x, y, 0), mapViewport.getScreenX(), mapViewport.getScreenY(), mapViewport.getScreenWidth(), mapViewport.getScreenHeight());
+ }
+
private void clampCameraPos()
{
float cx = cam.viewportWidth * cam.zoom / 2f;