Merge pull request #2834 from kevlahnota/newmaster2

update viewport
This commit is contained in:
Anthony Calosa
2023-04-06 07:11:10 +08:00
committed by GitHub
3 changed files with 14 additions and 4 deletions

View File

@@ -164,6 +164,9 @@ public class Forge implements ApplicationListener {
frameRate = new FrameRate();
animationBatch = new SpriteBatch();
inputProcessor = new MainInputProcessor();
//screenWidth and screenHeight should be set initially and only change upon restarting the app
screenWidth = Gdx.app.getGraphics().getWidth();
screenHeight = Gdx.app.getGraphics().getHeight();
Gdx.input.setInputProcessor(inputProcessor);
/*
@@ -958,15 +961,15 @@ public class Forge implements ApplicationListener {
@Override
public void resize(int width, int height) {
try {
screenWidth = width;
screenHeight = height;
if (currentScreen != null) {
currentScreen.setSize(width, height);
} else if (splashScreen != null) {
splashScreen.setSize(width, height);
}
if (currentScene != null)
currentScene.resize(width, height);
} catch (Exception ex) {
graphics.end();
//graphics.end();
//check if sentry is enabled, if not it will call the gui interface but here we end the graphics so we only send it via sentry..
if (BugReporter.isSentryEnabled())
BugReporter.reportException(ex);

View File

@@ -93,6 +93,9 @@ public abstract class Scene implements Disposable {
public void updateInput() {
}
public void resize(int width, int height) {
}
}

View File

@@ -192,7 +192,6 @@ public class UIScene extends Scene {
}
public UIScene(String uiFilePath) {
uiFile = uiFilePath;
stage = new Stage(new ScalingViewport(Scaling.stretch, getIntendedWidth(), getIntendedHeight())) {
@Override
@@ -711,4 +710,9 @@ public class UIScene extends Scene {
super.updateInput();
Gdx.input.setInputProcessor(stage);
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height, true);
}
}