feat: created StartScreen
really simple for now
This commit is contained in:
parent
3daea10663
commit
5de61a169d
|
@ -9,6 +9,9 @@ import com.badlogic.gdx.graphics.Color;
|
|||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
|
||||
import sagittarius.view.*;
|
||||
import sagittarius.model.*;
|
||||
|
||||
public class SagittariusGame extends Game {
|
||||
|
||||
// ---------- ATTRIBUTEs ----------
|
||||
|
@ -31,7 +34,7 @@ public class SagittariusGame extends Game {
|
|||
|
||||
@Override
|
||||
public void create() {
|
||||
setScreen(new GameScreen());
|
||||
setScreen(new StartScreen(this));
|
||||
|
||||
planetList = new ArrayList<Planet>();
|
||||
planetList.add( new Planet(new Vector2(400, 400), 1000, 50) );
|
||||
|
|
75
core/src/sagittarius/view/StartScreen.java
Normal file
75
core/src/sagittarius/view/StartScreen.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package sagittarius.view;
|
||||
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.ScreenAdapter;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
|
||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
import com.kotcrab.vis.ui.widget.VisTable;
|
||||
import com.kotcrab.vis.ui.widget.VisTextButton;
|
||||
|
||||
public class StartScreen extends ScreenAdapter {
|
||||
|
||||
private static final float WORLD_WIDTH = 1600;
|
||||
private static final float WORLD_HEIGHT = 900;
|
||||
|
||||
private final Game game;
|
||||
private Stage stage;
|
||||
|
||||
public StartScreen(Game game) {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
stage = new Stage(new FitViewport(WORLD_WIDTH, WORLD_HEIGHT));
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
|
||||
VisUI.load();
|
||||
VisTable root = new VisTable(true);
|
||||
root.setFillParent(true);
|
||||
stage.addActor(root);
|
||||
|
||||
VisTextButton startButton = new VisTextButton("start");
|
||||
startButton.addListener(new ActorGestureListener() {
|
||||
@Override
|
||||
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||
super.tap(event, x, y, count, button);
|
||||
game.setScreen(new GameScreen());
|
||||
}
|
||||
});
|
||||
|
||||
VisTextButton quitButton = new VisTextButton("quit");
|
||||
quitButton.addListener(new ActorGestureListener() {
|
||||
@Override
|
||||
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||
super.tap(event, x, y, count, button);
|
||||
Gdx.app.exit();
|
||||
}
|
||||
});
|
||||
|
||||
root.add(startButton);
|
||||
root.row();
|
||||
root.add(quitButton);
|
||||
root.row();
|
||||
}
|
||||
|
||||
public void resize(int width, int height) {
|
||||
stage.getViewport().update(width, height, true);
|
||||
}
|
||||
|
||||
public void render(float deltaTime) {
|
||||
stage.act(deltaTime);
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
VisUI.dispose();
|
||||
stage.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue