-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenuScreen.java
More file actions
133 lines (107 loc) · 3.79 KB
/
Copy pathMainMenuScreen.java
File metadata and controls
133 lines (107 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.david.piratepractice;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
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.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.utils.viewport.FitViewport;
/**
* Created by David on 12/17/2015.
*/
public class MainMenuScreen implements Screen{
Stage stage;
SpriteBatch batch;
PiratePractice game;
public MainMenuScreen(PiratePractice game) {
this.game = game;
create();
}
public void create () {
batch = new SpriteBatch();
stage = new Stage(new FitViewport(576, 1024));
Gdx.input.setInputProcessor(stage);
Table table = new Table();
table.setDebug(true);
table.setFillParent(true);
table.top();
stage.addActor(table);
Image menuImage = new Image(game.skin, "title");
table.add(menuImage).padTop(115).padBottom(96);
table.row();
Table buttonTable = new Table(game.skin);
buttonTable.setBackground("main button box");
buttonTable.setDebug(true);
table.add(buttonTable);
TextButton playButton = new TextButton("PLAY", game.skin, "main button");
playButton.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Play");
game.setScreen(new WorldScreen(game));
return false;
}
});
TextButton newButton = new TextButton("NEW GAME", game.skin, "main button");
newButton.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("New Game");
return false;
}
});
TextButton settingsButton = new TextButton("SETTINGS", game.skin, "main button");
settingsButton.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Settings");
return false;
}
});
TextButton exitButton = new TextButton("EXIT", game.skin, "main button");
exitButton.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Exit");
return false;
}
});
buttonTable.top();
buttonTable.add(playButton).padTop(64);
buttonTable.row();
buttonTable.add(newButton).padTop(64);
buttonTable.row();
buttonTable.add(settingsButton).padTop(64);
buttonTable.row();
buttonTable.add(exitButton).padTop(64).padBottom(64);
}
public void show() {}
@Override
public void render (float delta) {
Gdx.gl.glClearColor(0, .4745f, .749f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
stage.draw();
}
@Override
public void resize (int width, int height) {
stage.getViewport().update(width, height, true);
}
@Override
public void pause() {
}
@Override
public void resume() {
}
@Override
public void hide() {
}
@Override
public void dispose () {
stage.dispose();
}
}