summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2019-12-17 11:29:48 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2019-12-17 11:29:48 +0100
commite7a176f69cb11dda58f05347349ce096bc7f3008 (patch)
treea09badd9ceae2c8e2e17a7dedc1336cab58d6f30
parente868bcd276ca812feed08e01a8c4400f6c228408 (diff)
downloadgdx-boardgame-e7a176f69cb11dda58f05347349ce096bc7f3008.zip
gdx-boardgame-e7a176f69cb11dda58f05347349ce096bc7f3008.tar.gz
test : fix OrthographicCamera usage and Root resizing
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java13
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java3
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java9
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/UiScreen.java9
4 files changed, 7 insertions, 27 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java
index 767a4ea..fdceda6 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/AbstractScreen.java
@@ -68,18 +68,11 @@ public abstract class AbstractScreen implements Screen
batch.end();
}
- public void resize(int width, int height, float ratio)
+ @Override public void resize(int width, int height)
{
GdxBoardTest.debug(dom, String.format("resize (%d,%d)", width, height));
- if (width >= height) {
- camera.viewportWidth = bg.getWidth();
- camera.viewportHeight = bg.getHeight() / (float)width * (float)height;
- } else {
- camera.viewportHeight = bg.getHeight();
- camera.viewportWidth = bg.getWidth() / (float)height * (float)width;
- }
- camera.viewportWidth *= ratio;
- camera.viewportHeight *= ratio;
+ camera.viewportWidth = width;
+ camera.viewportHeight = height;
camera.update();
root.resize(
camera.position.x - (camera.viewportWidth / 2f),
diff --git a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java
index 8deefa5..19602ee 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java
@@ -202,8 +202,9 @@ public class AnimationsScreen extends AbstractScreen
@Override public void resize(int width, int height)
{
- GdxBoardTest.debug("BoardScrean", String.format("resize (%d,%d)",width, height));
+ GdxBoardTest.debug("AnimationScrean", String.format("resize (%d,%d)",width, height));
cam.updateViewport(width, height);
+ root.resize(cam.getHud());
}
@Override protected void onZoom(float dz) { }
diff --git a/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java b/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java
index bf6ae23..95dbd80 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/MenuScreen.java
@@ -9,7 +9,6 @@ import ch.asynk.gdx.boardgame.ui.Menu;
public class MenuScreen extends AbstractScreen
{
- private final float WORLD_RATIO = 0.5f;
private final Sprite corner;
private final Menu menu;
@@ -31,9 +30,8 @@ public class MenuScreen extends AbstractScreen
this.menu.setLabelsOffset(10);
this.root.add(this.menu);
- this.camera = new OrthographicCamera(bg.getWidth() * WORLD_RATIO, bg.getHeight() * WORLD_RATIO);
+ this.camera = new OrthographicCamera();
this.camera.position.set(bg.getWidth() / 2f, bg.getHeight() / 2f, 0);
- this.camera.update();
}
@Override protected void draw(SpriteBatch batch)
@@ -61,11 +59,6 @@ public class MenuScreen extends AbstractScreen
corner.draw(batch);
}
- @Override public void resize(int width, int height)
- {
- resize(width, height, WORLD_RATIO);
- }
-
@Override protected void onZoom(float dz) { }
@Override protected void onDragged(int dx, int dy) { }
@Override protected void onTouch(int x, int y)
diff --git a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java
index 87c182d..f94e4f7 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java
@@ -24,7 +24,6 @@ class MyButton extends Button
public class UiScreen extends AbstractScreen
{
- private final float WORLD_RATIO = 0.5f;
private final Button next;
private final Button[] buttons = new Button[8];
@@ -66,9 +65,8 @@ public class UiScreen extends AbstractScreen
this.next.setLabelAlignment(Alignment.TOP_LEFT);
this.root.add(this.next);
- this.camera = new OrthographicCamera(bg.getWidth() * WORLD_RATIO, bg.getHeight() * WORLD_RATIO);
+ this.camera = new OrthographicCamera();
this.camera.position.set(bg.getWidth() / 2f, bg.getHeight() / 2f, 0);
- this.camera.update();
setState(State.POSITIONS);
}
@@ -113,11 +111,6 @@ public class UiScreen extends AbstractScreen
}
}
- @Override public void resize(int width, int height)
- {
- resize(width, height, WORLD_RATIO);
- }
-
@Override protected void onZoom(float dz) { }
@Override protected void onDragged(int dx, int dy) { }
@Override protected void onTouch(int x, int y)