diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-12-28 20:09:48 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-12-28 20:09:48 +0100 |
commit | da40130331b292b6b4a143959fe111a9312d8f9d (patch) | |
tree | cc5d3e82c393063f91211d5afdb98fa8529f5065 /core | |
parent | d162488fc655cf55bcf7399ecdb4df8b900694c6 (diff) | |
download | RustAndDust-da40130331b292b6b4a143959fe111a9312d8f9d.zip RustAndDust-da40130331b292b6b4a143959fe111a9312d8f9d.tar.gz |
GameCamera: fix aspect computation
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/screens/GameCamera.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameCamera.java b/core/src/ch/asynk/tankontank/screens/GameCamera.java index 14c308b..462745c 100644 --- a/core/src/ch/asynk/tankontank/screens/GameCamera.java +++ b/core/src/ch/asynk/tankontank/screens/GameCamera.java @@ -40,13 +40,14 @@ public class GameCamera extends OrthographicCamera float viewportAspect = (viewportWidth / viewportHeight); float aspect = (screenWidth / (float) screenHeight); + float diff = (viewportAspect - aspect); - if ((viewportAspect - aspect) < ZEROF) { + if (diff < -ZEROF) { screen.width = (screenHeight * viewportAspect); screen.height = screenHeight; screen.x = ((screenWidth - screen.width) / 2f); screen.y = 0f; - } else { + } else if (diff > ZEROF) { screen.width = screenWidth; screen.height = (screenWidth / viewportAspect); screen.x = 0f; |