From da40130331b292b6b4a143959fe111a9312d8f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 28 Dec 2014 20:09:48 +0100 Subject: GameCamera: fix aspect computation --- core/src/ch/asynk/tankontank/screens/GameCamera.java | 5 +++-- 1 file 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; -- cgit v1.1-2-g2b99