From 8b95bc03a5ee18a54b16de87f5f2dd37e1b0b4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Fri, 23 Apr 2021 17:32:17 +0200 Subject: [PATCH] feat: really basic zoom functionnality --- core/src/sagittarius/view/GameScreen.java | 12 ++++++++++-- core/src/sagittarius/view/SettingsScreen.java | 4 ++-- desktop/src/sagittarius/desktop/DesktopLauncher.java | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/sagittarius/view/GameScreen.java b/core/src/sagittarius/view/GameScreen.java index e9231e4..0b99dd5 100644 --- a/core/src/sagittarius/view/GameScreen.java +++ b/core/src/sagittarius/view/GameScreen.java @@ -1,14 +1,14 @@ package sagittarius.view; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.scenes.scene2d.Group; -import org.omg.CORBA.Current; - import sagittarius.SagittariusGame; import sagittarius.model.*; @@ -43,6 +43,8 @@ public class GameScreen extends BaseScreen { @Override public void initialize() { + Gdx.input.setInputProcessor(null); // on a pas de boutons + // planets & moons attractors = new Group(); @@ -118,6 +120,12 @@ public class GameScreen extends BaseScreen { mainCameraPosition.scl(ispeed); mainCameraPosition.add(new Vector3(focus.getPosition(), 0).scl(speed)); + if (Gdx.input.isButtonPressed(Buttons.LEFT)) { + ((OrthographicCamera) mainStage.getCamera()).zoom = 2f; + } else { + ((OrthographicCamera) mainStage.getCamera()).zoom = 1f; + } + } /** diff --git a/core/src/sagittarius/view/SettingsScreen.java b/core/src/sagittarius/view/SettingsScreen.java index 6f5a744..943226c 100644 --- a/core/src/sagittarius/view/SettingsScreen.java +++ b/core/src/sagittarius/view/SettingsScreen.java @@ -19,12 +19,12 @@ public class SettingsScreen extends BaseScreen { @Override public void initialize() { - Gdx.input.setInputProcessor(mainStage); + Gdx.input.setInputProcessor(uiStage); // Table creation VisTable table = new VisTable(true); table.setFillParent(true); - mainStage.addActor(table); + uiStage.addActor(table); VisLabel errorLabel = new VisLabel(); errorLabel.setColor(Color.RED); diff --git a/desktop/src/sagittarius/desktop/DesktopLauncher.java b/desktop/src/sagittarius/desktop/DesktopLauncher.java index 8c1df7e..e308b08 100644 --- a/desktop/src/sagittarius/desktop/DesktopLauncher.java +++ b/desktop/src/sagittarius/desktop/DesktopLauncher.java @@ -12,6 +12,7 @@ public class DesktopLauncher { config.setForegroundFPS(120); config.setWindowedMode(1920, 1080); config.setDecorated(false); + config.setResizable(false); new Lwjgl3Application(new SagittariusGame(), config);