use of com.badlogic.gdx.scenes.scene2d.ui.Label in project AmazingMaze by TheVirtualMachine.
the class FishMiniGame method dialog.
/**
* Displays the results dialog.
*/
public void dialog() {
message = formatString(answerField.getText());
Label.LabelStyle labelStyle = new Label.LabelStyle(game.assets.getFont(Assets.MONO_REGULAR, Assets.SMALL_FONT_SIZE), Color.WHITE);
final Dialog dialog = new Dialog("Results", game.assets.skin);
final TextButton okButton = new TextButton("OK", game.assets.skin);
dialog.getButtonTable().bottom();
if (checkAnswer() == -1) {
Label label = new Label("Invalid answer. Please try again.", labelStyle);
label.setScale(.5f);
label.setWrap(true);
label.setAlignment(Align.center);
dialog.add(label).width(500).pad(50);
dialog.add(okButton).bottom();
okButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (okButton.isPressed()) {
dialog.hide();
canvas.setColor(drawColor);
}
}
});
dialog.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Keys.ENTER) {
dialog.hide();
return true;
}
return false;
}
});
} else {
Label label = new Label("Your answer was: " + message + ". " + "The correct answer was: " + answer + ". " + "You get " + checkAnswer() + " back!", labelStyle);
game.save.addScore(checkAnswer());
game.save.setLives(player.getLives());
label.setScale(.5f);
label.setWrap(true);
label.setAlignment(Align.center);
dialog.add(label).width(500).pad(50);
dialog.add(okButton).bottom();
okButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (okButton.isPressed()) {
dialog.cancel();
if ((game.save.getLevel() - 1) % 5 == 0) {
game.setScreen(new ContinueScreen(game, true));
} else {
game.setScreen(new MazeScreen(game, false));
}
}
}
});
dialog.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Keys.ENTER) {
if ((game.save.getLevel() - 1) % 5 == 0) {
game.setScreen(new ContinueScreen(game, true));
} else {
game.setScreen(new MazeScreen(game, false));
}
return true;
}
return false;
}
});
}
dialog.show(stage);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Label in project AmazingMaze by TheVirtualMachine.
the class ContinueScreen method highScoreDialog.
/**
* Displays the high score dialog.
*/
public void highScoreDialog() {
Label.LabelStyle labelStyle = new Label.LabelStyle(game.assets.getFont(Assets.MONO_REGULAR, Assets.SMALL_FONT_SIZE), Color.WHITE);
final Dialog dialog = new Dialog("High Score", game.assets.skin);
final TextButton okButton = new TextButton("OK", game.assets.skin);
dialog.getButtonTable().bottom();
Label label = new Label("Enter your name:", labelStyle);
label.setScale(.5f);
label.setWrap(true);
label.setAlignment(Align.center);
final TextField nameField = new TextField("", game.assets.skin);
dialog.add(label).width(500).pad(50);
dialog.add(nameField);
dialog.add(okButton).bottom();
nameField.setTextFieldListener(new TextFieldListener() {
@Override
public void keyTyped(TextField textField, char key) {
name = formatString(nameField.getText());
if (!name.equals("")) {
if (key == (char) 13) {
displayHighScores(name);
}
}
}
});
okButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
name = formatString(nameField.getText());
if (!name.equals("")) {
if (okButton.isPressed()) {
dialog.hide();
displayHighScores(name);
}
}
}
});
dialog.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
name = formatString(nameField.getText());
if (!name.equals("")) {
if (keycode == Keys.ENTER) {
displayHighScores(name);
return true;
}
}
return false;
}
});
dialog.show(stage);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Label in project AmazingMaze by TheVirtualMachine.
the class CreditsScreen method setupComponents.
/**
* Instantiate the stage and its actors for the credits screen.
* Add all actors to the stage.
*/
private void setupComponents() {
stage = new Stage();
table = new Table();
table.top();
table.setFillParent(true);
stage.addActor(table);
gameLogo = new Image(game.assets.manager.get(Assets.GAME_LOGO, Texture.class));
header = new Label("", game.assets.skin, Assets.SERIF_HEADER_STYLE);
codeGroup = setupCreditsLabel(CODE, Assets.CREDITS_CONTENTS);
artGroup = setupCreditsLabel(ART, Assets.CREDITS_CONTENTS);
storyGroup = setupCreditsLabel(STORY, Assets.CREDITS_CONTENTS);
musicGroup = setupCreditsLabel(MUSIC, Assets.SMALL_CREDITS_CONTENTS);
thanksGroup = setupCreditsLabel(THANKS, Assets.CREDITS_CONTENTS);
companyLogo = new Image(game.assets.manager.get(Assets.COMPANY_LOGO, Texture.class));
}
use of com.badlogic.gdx.scenes.scene2d.ui.Label in project AmazingMaze by TheVirtualMachine.
the class CreditsScreen method setupCreditsLabel.
/**
* Helper method to create centred labels.
*
* @param lines the lines to put in the label. Assumed to have at least one element.
* @param skin the skin to load the style from.
* @return a new {@link Label} with the given properties.
*/
private Label setupCreditsLabel(String[] lines, String style) {
String s = lines[0];
for (int i = 1; i < lines.length; i++) {
s += "\n" + lines[i];
}
Label label = new Label(s, game.assets.skin, style);
label.setAlignment(Align.center);
return label;
}
use of com.badlogic.gdx.scenes.scene2d.ui.Label in project AmazingMaze by TheVirtualMachine.
the class StoryScreen method setupUI.
/** Helper method to setup the UI. */
private void setupUI() {
stage = new Stage(new ScreenViewport(), game.batch);
table = new Table();
table.top().center();
table.setFillParent(true);
stage.addActor(table);
header = new Label("Story", game.assets.skin, Assets.SERIF_HEADER_STYLE);
table.add(header).padTop(Gdx.graphics.getHeight() / 25f);
storyLabel = new Label(readStory(), game.assets.skin, Assets.STORY_STYLE);
storyLabel.setWrap(true);
table.row();
table.add(storyLabel).maxWidth(Gdx.graphics.getWidth()).prefWidth(Gdx.graphics.getWidth() / 1.125f).pad(Gdx.graphics.getHeight() / 25f);
continueButton = new TextButton("Continue...", game.assets.skin);
continueButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (continueButton.isPressed()) {
game.setScreen(new MazeScreen(game, false));
}
}
});
table.row();
table.add(continueButton).width(Gdx.graphics.getWidth() / 4f).pad(Gdx.graphics.getHeight() / 25f).expandY().bottom().fillY();
}
Aggregations