Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainMenu implements Screen{
- private Game game;
- private Stage stage;
- private Table table;
- private Skin skin;
- private TextureAtlas atlas;
- private TextButton playButton;
- private BitmapFont white;
- private Label heading;
- private Label.LabelStyle headingStyle;
- public MainMenu(Game gam){
- game = gam;
- stage = new Stage();
- Gdx.input.setInputProcessor(stage);
- white = new BitmapFont(Gdx.files.internal("fonts/white.fnt"), false);
- atlas = new TextureAtlas("ui/button.pack");
- skin = new Skin(atlas);
- table = new Table(skin);
- table.setFillParent(true);
- TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle();
- buttonStyle.up = skin.getDrawable("buttonUp");
- buttonStyle.down = skin.getDrawable("buttonDown");
- buttonStyle.pressedOffsetX = 1;
- buttonStyle.pressedOffsetY = -1;
- buttonStyle.font = white;
- buttonStyle.fontColor = Color.BLACK;
- playButton = new TextButton("PLAY", buttonStyle);
- playButton.pad(30);
- playButton.addListener(new ChangeListener() {
- @Override
- public void changed(ChangeEvent event, Actor actor) {
- game.setScreen(new GamePlay());
- }
- });
- headingStyle = new Label.LabelStyle(white, Color.WHITE);
- heading = new Label(GAMETITLE, headingStyle);
- heading.setFontScale(1);
- table.add(heading);
- table.getCell(heading).spaceBottom(100);
- table.row();
- table.add(playButton);
- table.debug();
- stage.addActor(table);
- }
- @Override
- public void render(float delta) {
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- table.act(delta);
- stage.draw();
- }
- @Override
- public void dispose() {
- stage.dispose();
- atlas.dispose();
- skin.dispose();
- white.dispose();
- }
- @Override
- public void show() {
- }
- @Override
- public void resize(int width, int height) {
- }
- @Override
- public void pause() {
- }
- @Override
- public void resume() {
- }
- @Override
- public void hide() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement