added MainMenu

This commit is contained in:
Anastron 2014-08-11 15:30:43 +02:00
parent 57da84eb7a
commit 91f91ab4b0
9 changed files with 1829 additions and 7 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,11 @@
{
"com.badlogic.gdx.graphics.g2d.BitmapFont": {
"font": { "file": "fonts/font.fnt" },
},
"com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
"default": { "up": "blue_button2" , "down": "blue_button3", "font": font, "pressedOffsetY": -4 }
},
"com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle": {
"default": { "font": font}
}
}

View File

@ -0,0 +1,155 @@
menuSkin.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
blue_panel
rotate: false
xy: 1, 23
size: 100, 100
split: 39, 60, 42, 57
orig: 100, 100
offset: 0, 0
index: -1
blue_button1
rotate: false
xy: 103, 74
size: 49, 49
split: 6, 6, 7, 10
orig: 49, 49
offset: 0, 0
index: -1
blue_button2
rotate: false
xy: 103, 23
size: 49, 49
split: 7, 7, 5, 9
orig: 49, 49
offset: 0, 0
index: -1
blue_button4
rotate: false
xy: 154, 74
size: 49, 49
split: 12, 19, 7, 10
orig: 49, 49
offset: 0, 0
index: -1
blue_button6
rotate: false
xy: 154, 23
size: 49, 49
split: 9, 12, 6, 10
orig: 49, 49
offset: 0, 0
index: -1
blue_button3
rotate: false
xy: 205, 78
size: 49, 45
split: 15, 15, 5, 7
orig: 49, 45
offset: 0, 0
index: -1
blue_button5
rotate: false
xy: 205, 31
size: 49, 45
split: 7, 8, 7, 8
orig: 49, 45
offset: 0, 0
index: -1
blue_button7
rotate: false
xy: 256, 78
size: 49, 45
split: 9, 11, 5, 5
orig: 49, 45
offset: 0, 0
index: -1
blue_boxCheckmark
rotate: false
xy: 256, 40
size: 38, 36
orig: 38, 36
offset: 0, 0
index: -1
blue_boxCross
rotate: false
xy: 307, 87
size: 38, 36
orig: 38, 36
offset: 0, 0
index: -1
grey_box
rotate: false
xy: 347, 87
size: 38, 36
orig: 38, 36
offset: 0, 0
index: -1
blue_circle
rotate: false
xy: 387, 87
size: 36, 36
split: 17, 18, 17, 18
orig: 36, 36
offset: 0, 0
index: -1
blue_sliderLeft
rotate: false
xy: 425, 92
size: 39, 31
orig: 39, 31
offset: 0, 0
index: -1
blue_sliderRight
rotate: false
xy: 466, 92
size: 39, 31
orig: 39, 31
offset: 0, 0
index: -1
blue_sliderDown
rotate: false
xy: 296, 34
size: 28, 42
orig: 28, 42
offset: 0, 0
index: -1
blue_sliderUp
rotate: false
xy: 326, 43
size: 28, 42
orig: 28, 42
offset: 0, 0
index: -1
blue_checkmark
rotate: false
xy: 1, 1
size: 21, 20
orig: 21, 20
offset: 0, 0
index: -1
blue_cross
rotate: false
xy: 356, 67
size: 18, 18
orig: 18, 18
offset: 0, 0
index: -1
blue_selection
rotate: false
xy: 24, 4
size: 17, 17
split: 8, 8, 8, 8
orig: 17, 17
offset: 0, 0
index: -1
blue_selection
rotate: false
xy: 24, 4
size: 17, 17
orig: 17, 17
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -1,13 +1,34 @@
package de.samdev.clorrunner.screens.menu;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
public class MainMenu implements Screen {
private Stage stage = new Stage();
private Table table = new Table();
private Skin skin = new Skin(Gdx.files.internal("skins/menuSkin.json"),
new TextureAtlas(Gdx.files.internal("skins/menuSkin.pack")));
private TextButton buttonPlay = new TextButton("Play", skin),
buttonExit = new TextButton("Exit", skin);
private Label title = new Label("Color Runner", skin);
@Override
public void render(float delta) {
@ -27,7 +48,29 @@ public class MainMenu implements Screen {
@Override
public void show() {
// TODO Auto-generated method stub
buttonPlay.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
((Game)Gdx.app.getApplicationListener()).setScreen(new GameScreen());
}
});
buttonExit.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
// or System.exit(0);
}
});
table.add(title).padBottom(40).row();
table.add(buttonPlay).size(150,60).padBottom(20).row();
table.add(buttonExit).size(150,60).padBottom(20).row();
table.setFillParent(true);
stage.addActor(table);
Gdx.input.setInputProcessor(stage);
}
@ -52,7 +95,7 @@ public class MainMenu implements Screen {
@Override
public void dispose() {
stage.dispose();
skin.dispose();
}
}

View File

@ -10,7 +10,6 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.MathUtils;
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
public class SplashScreen implements Screen {
@ -57,7 +56,7 @@ public class SplashScreen implements Screen {
loadTime += delta;
if (loadTime > 0.5)
((Game) Gdx.app.getApplicationListener()).setScreen(new GameScreen());
((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
}

View File

@ -8,7 +8,8 @@ import de.samdev.colorrunner.screens.gameScreen.GameScreen;
public class CRGame extends Game {
private SplashScreen SplashScreen;
public static final int WIDTH=1000,HEIGHT=563;
@Override
public void create() {
SplashScreen = new SplashScreen();

View File

@ -9,8 +9,8 @@ public class DesktopLauncher {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "ColorRunner";
config.width = 1000;
config.height = 563;
config.width = CRGame.WIDTH;
config.height = CRGame.HEIGHT;
/*
* For FPS Independence Testing