List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Table setSkin
public void setSkin(Skin skin)
From source file:ateamproject.kezuino.com.github.render.screens.HighscoreScreen.java
public HighscoreScreen(Game game, boolean top10HighscoreReached) { super(game);/*from w ww. j av a 2 s. c om*/ TextButton btnBack = new TextButton("Terug", skin); btnBack.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (top10HighscoreReached) { game.setScreen(new CreditsScreen(game)); } else { game.setScreen(new MainScreen(game)); } } }); float x = 240; float y = stage.getHeight() / 4; btnBack.setSize(200, 40); btnBack.setPosition(stage.getWidth() / 2 - btnBack.getWidth() / 2, stage.getHeight() / 4 - btnBack.getHeight() / 2); Label lblTitle = new Label("Highscore", skin); if (top10HighscoreReached) { lblTitle = new Label("Gefeliciteerd met een top 10 plek!", skin); btnBack.setText("Haal mijn prijs op"); } lblTitle.setColor(Color.YELLOW); lblTitle.setPosition(stage.getWidth() / 2 - lblTitle.getWidth() / 2, stage.getHeight() - 50); PacketGetHighscores packet = new PacketGetHighscores(Client.getInstance().getId()); Client.getInstance().send(packet); Table table = new Table(); table.setSkin(skin); int rankNr = 0; for (Map.Entry<String, Integer> entry : packet.getResult().entrySet()) { rankNr++; table.add(new Label(Integer.toString(rankNr), skin)).padRight(50); table.add(new Label(entry.getKey(), skin)).padRight(50); table.add(new Label(Integer.toString(entry.getValue()), skin)); table.row(); } table.setPosition(stage.getWidth() / 2 - table.getWidth() / 2, stage.getHeight() - 190); stage.addActor(btnBack); stage.addActor(lblTitle); stage.addActor(table); backgroundMusic = Assets.getMusicStream("menu.mp3"); }
From source file:de.fgerbig.spacepeng.screens.CreditsScreen.java
License:Open Source License
@Override public void show() { super.show(); // retrieve the default table actor Table table = super.getTable(); table.setSkin(game.getSkin()); Label label = new Label("Credits", game.getSkin()); label.setStyle(labelStyle_Heading);/*w ww . j a v a 2s . c om*/ table.add(label).spaceBottom(25); table.row(); Label creditsText = new Label(CREDITS, game.getSkin()); Label.LabelStyle labelStyle = creditsText.getStyle(); labelStyle.font = game.getFont(); creditsText.setStyle(labelStyle); creditsText.setAlignment(Align.center); ScrollPane scrollPane = new ScrollPane(creditsText); table.add(scrollPane).size(CREDITS_WIDTH, CREDITS_HEIGHT).spaceBottom(25); table.row(); // register the back button TextButton backButton = new TextButton("Back", game.getSkin()); backButton.setStyle(textButtonStyle_Default); backButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.setScreen(new MenuScreen(game)); } }); table.row(); table.add(backButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).colspan(3); }
From source file:de.fgerbig.spacepeng.screens.MenuScreen.java
License:Apache License
public MenuScreen(final SpacePeng game) { super(game);//from w ww . j a v a 2 s. c o m // retrieve the default table actor Table table = super.getTable(); table.setSkin(game.getSkin()); Label label = new Label("SPACE PENG!", game.getSkin()); label.setStyle(labelStyle_Heading); table.add(label).spaceBottom(25); table.row(); profile = SpacePeng.profileManager.retrieveProfile(); if (profile.getLastPlayedLevel() > 1) { // register the button "start game" continueGameButton = new TextButton("Level " + profile.getLastPlayedLevel(), game.getSkin()); continueGameButton.setStyle(textButtonStyle_Default); continueGameButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.setScreen(new GameScreen(game)); } }); table.add(continueGameButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform() .spaceBottom(BUTTON_HEIGHT / 3); table.row(); } // register the button "start game" String title = (profile.getLastPlayedLevel() > 1) ? "RESTART" : "START"; startGameButton = new TextButton(title, game.getSkin()); startGameButton.setStyle(textButtonStyle_Default); startGameButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); profile.setLastPlayedLevel(1); game.setScreen(new GameScreen(game)); } }); table.add(startGameButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().spaceBottom(BUTTON_SPACING); table.row(); // register the button "Credits" creditsButton = new TextButton("Credits", game.getSkin()); creditsButton.setStyle(textButtonStyle_Default); creditsButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.setScreen(new CreditsScreen(game)); } }); table.add(creditsButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().fill().spaceBottom(BUTTON_SPACING); table.row(); // register the button "options" optionsButton = new TextButton("Options", game.getSkin()); optionsButton.setStyle(textButtonStyle_Default); optionsButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.setScreen(new OptionsScreen(game)); } }); table.add(optionsButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().fill().spaceBottom(BUTTON_HEIGHT / 3); table.row(); // register the button "quit" quitButton = new TextButton("QUIT", game.getSkin()); quitButton.setStyle(textButtonStyle_Default); quitButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.pause(); game.dispose(); } }); table.add(quitButton).size(BUTTON_WIDTH, BUTTON_HEIGHT); Cell cell; if (profile.getLastPlayedLevel() > 1) { cell = table.getCell(continueGameButton); continueGameButton_w = cell.getMaxWidth(); continueGameButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); } cell = table.getCell(startGameButton); startGameButton_w = cell.getMaxWidth(); startGameButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); cell = table.getCell(creditsButton); creditsButton_w = cell.getMaxWidth(); creditsButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); cell = table.getCell(optionsButton); optionsButton_w = cell.getMaxWidth(); optionsButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); cell = table.getCell(quitButton); quitButton_w = cell.getMaxWidth(); quitButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); getTable().invalidate(); }