refactorerte code

This commit is contained in:
Tobydrama 2020-04-02 12:47:42 +02:00
parent 733960bebc
commit 94ed63be3c

View File

@ -19,7 +19,6 @@ public class PowerDownScreen extends AbstractScreen {
private long startTime; private long startTime;
private final int applicationWidth = 600; private final int applicationWidth = 600;
private final int applicationHeight = 800; private final int applicationHeight = 800;
private Boolean buttonPressed = false;
public PowerDownScreen(final RoboRallyWrapper roboRallyWrapper) { public PowerDownScreen(final RoboRallyWrapper roboRallyWrapper) {
camera = new OrthographicCamera(); camera = new OrthographicCamera();
viewport = new FitViewport(applicationWidth, applicationHeight, camera); viewport = new FitViewport(applicationWidth, applicationHeight, camera);
@ -35,7 +34,7 @@ public class PowerDownScreen extends AbstractScreen {
powerDownButton.addListener(new InputListener() { powerDownButton.addListener(new InputListener() {
@Override @Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
buttonPressed = true; roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(roboRallyWrapper));
return true;//her we do stuff return true;//her we do stuff
} }
}); });
@ -60,11 +59,7 @@ public class PowerDownScreen extends AbstractScreen {
stage.draw(); stage.draw();
if (elapsedTime > 10) { if (elapsedTime > 10) {
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getMainMenuScreen(this.roboRallyWrapper));
dispose();
} else if (buttonPressed) {
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper)); roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
dispose();
} }
} }
@ -73,4 +68,9 @@ public class PowerDownScreen extends AbstractScreen {
viewport.update(width, height); viewport.update(width, height);
} }
@Override
public void show(){
startTime = System.currentTimeMillis();
}
} }