mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-07 18:49:34 +01:00
lagde en powerdown screen som går vekk etter 10 sekunder
This commit is contained in:
parent
4c8e703c95
commit
f6e397063f
@ -0,0 +1,93 @@
|
||||
package inf112.fiasko.roborally.game_wrapper;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||
|
||||
public class PowerDownScreen implements Screen {
|
||||
private final RoboRallyWrapper roboRallyWrapper;
|
||||
|
||||
private final OrthographicCamera camera;
|
||||
private final Viewport viewport;
|
||||
private final Stage stage;
|
||||
private long startTime;
|
||||
private final int applicationWidth = 600;
|
||||
private final int applicationHeight = 800;
|
||||
public PowerDownScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
camera = new OrthographicCamera();
|
||||
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||
stage = new Stage();
|
||||
TextButton powerDownButton = new SimpleButton("PowerDown", roboRallyWrapper.font).getButton();
|
||||
stage.addActor(powerDownButton);
|
||||
powerDownButton.setY(applicationHeight/2f);
|
||||
powerDownButton.setX(applicationWidth/2f+powerDownButton.getWidth()/4f);
|
||||
this.roboRallyWrapper = roboRallyWrapper;
|
||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
startTime = System.currentTimeMillis();
|
||||
powerDownButton.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
//Nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0.2f, 1f, 0.2f, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
camera.update();
|
||||
roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
|
||||
|
||||
roboRallyWrapper.batch.begin();
|
||||
roboRallyWrapper.font.draw(roboRallyWrapper.batch, "click to go in PowerDown you have 10 seconds",
|
||||
applicationWidth/2f-380/2f,applicationHeight/2f +100,380, 1, true);
|
||||
roboRallyWrapper.batch.end();
|
||||
stage.draw();
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
if (time-startTime>10000){
|
||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getMainMenuScreen(this.roboRallyWrapper));
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
viewport.update(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
//Nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
//Nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
//Nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
//Nothing to do
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user