Merge remote-tracking branch 'origin/master'

This commit is contained in:
Mike Schwörer 2014-08-11 18:23:15 +02:00
commit 809192ba95
2 changed files with 115 additions and 3 deletions

View File

@ -25,7 +25,8 @@ public class MainMenu implements Screen {
private TextButton buttonPlay = new TextButton("Play", skin),
buttonExit = new TextButton("Exit", skin);
buttonExit = new TextButton("Exit", skin),
buttonOption = new TextButton("Option", skin);
private Label title = new Label("Color Runner", skin);
@ -55,6 +56,13 @@ public class MainMenu implements Screen {
}
});
buttonOption.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
((Game)Gdx.app.getApplicationListener()).setScreen(new OptionMenuScreen());
}
});
buttonExit.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
@ -64,8 +72,9 @@ public class MainMenu implements Screen {
});
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.add(buttonPlay).size((int)((double)Gdx.graphics.getWidth() / 2.0D),60).padBottom(20).row();
table.add(buttonOption).size((int)((double)Gdx.graphics.getWidth() / 2.0D),60).padBottom(20).row();
table.add(buttonExit).size((int)((double)Gdx.graphics.getWidth() / 2.0D),60).padBottom(20).row();
table.setFillParent(true);
stage.addActor(table);

View File

@ -0,0 +1,103 @@
package de.samdev.colorrunner.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 OptionMenuScreen 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 Label title = new Label("Option", skin);
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act();
stage.draw();
}
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void show() {
TextButton buttonSound = new TextButton("Sound On/Off", skin);
TextButton buttonBack = new TextButton("Back", skin);
buttonSound.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
}
});
buttonBack.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
((Game)Gdx.app.getApplicationListener()).setScreen(new MainMenu());
}
});
table.add(title).padBottom(40).row();
table.add(buttonSound).size((int)((double)Gdx.graphics.getWidth() / 2.0D),70).padBottom(20).row();
table.add(buttonBack).size((int)((double)Gdx.graphics.getWidth() / 2.0D), 70).padBottom(20).row();
table.setFillParent(true);
stage.addActor(table);
Gdx.input.setInputProcessor(stage);
}
@Override
public void hide() {
dispose();
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
stage.dispose();
skin.dispose();
}
}