use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.
the class PantallaScoresStory method crearMenu.
@Override
void crearMenu() {
super.stageMenu = new Stage(vista);
title = new Texto(1, 1, 1);
imgBackground = new Texture("logros.png");
spriteBackground = new Sprite(imgBackground);
spriteBackground.setPosition(0, 0);
// spriteBackground.setAlpha(0.7f);
// Skin skin = new Skin(Gdx.files.internal("skin/comic-ui.json"));
Skin skin = new Skin(Gdx.files.internal("skin5/star-soldier-ui.json"));
// Skin skin = new Skin(Gdx.files.internal("skin2/glassy-ui.json"));
Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
String score = prefs.getString("highscores", null);
ArrayList<String> scoress = new ArrayList<String>();
if (score == null) {
// prefs.putString("highscores", "10000");
scoress.add("Astro:10000");
} else {
for (String s : score.split(",")) {
if (s.length() > 1) {
scoress.add(s);
}
}
}
Table table = new Table(skin);
table.defaults().pad(10f);
table.setFillParent(true);
table.setPosition(table.getX(), table.getY() + 130);
/**
* Se crean las columnas con puntuajes
*/
Label columnName;
Label columnScore;
ArrayList<String> allScores = new ArrayList<String>();
ArrayList<String> allNames = new ArrayList<String>();
for (String s : scoress) {
allScores.add(s.split(":")[1]);
allNames.add(s.split(":")[0]);
}
int i = 0;
// table.add(scoresTitle).colspan(2).fillX().height(150);
table.row();
for (String name : allNames) {
columnName = new Label(name + ": ", skin);
columnName.setFontScale(1.5f, 1.5f);
table.add(columnName);
columnScore = new Label(allScores.get(i), skin);
columnScore.setFontScale(1.5f, 1.5f);
table.add(columnScore);
i++;
table.row();
}
// Boton Return
TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
ImageButton btnReturn = new ImageButton(trdReturn);
btnReturn.setPosition(30, ALTO - 30 - btnReturn.getHeight());
// Click en boton Return
btnReturn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
main.setScreen(new PantallaMenu(main));
}
});
stageMenu.addActor(table);
stageMenu.addActor(btnReturn);
Gdx.input.setInputProcessor(stageMenu);
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.
the class PantallaScoresSurvival method crearMenu.
@Override
void crearMenu() {
super.stageMenu = new Stage(vista);
title = new Texto(1, 1, 1);
imgBackground = new Texture("logros.png");
spriteBackground = new Sprite(imgBackground);
spriteBackground.setPosition(0, 0);
// spriteBackground.setAlpha(0.7f);
// Skin skin = new Skin(Gdx.files.internal("skin/comic-ui.json"));
Skin skin = new Skin(Gdx.files.internal("skin5/star-soldier-ui.json"));
// Skin skin = new Skin(Gdx.files.internal("skin2/glassy-ui.json"));
Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceSurvival");
String score = prefs.getString("highscores", null);
ArrayList<String> scoress = new ArrayList<String>();
if (score == null) {
// prefs.putString("highscores", "10000");
scoress.add("Astro:10000");
} else {
for (String s : score.split(",")) {
if (s.length() > 1) {
scoress.add(s);
}
}
}
Table table = new Table(skin);
table.defaults().pad(10f);
table.setFillParent(true);
table.setPosition(table.getX(), table.getY() + 130);
/**
* Se crean las columnas con puntuajes
*/
Label columnName;
Label columnScore;
ArrayList<String> allScores = new ArrayList<String>();
ArrayList<String> allNames = new ArrayList<String>();
for (String s : scoress) {
allScores.add(s.split(":")[1]);
allNames.add(s.split(":")[0]);
}
int i = 0;
// table.add(scoresTitle).colspan(2).fillX().height(150);
table.row();
for (String name : allNames) {
columnName = new Label(name + ": ", skin);
columnName.setFontScale(1.5f, 1.5f);
table.add(columnName);
columnScore = new Label(allScores.get(i), skin);
columnScore.setFontScale(1.5f, 1.5f);
table.add(columnScore);
i++;
table.row();
}
// Boton Return
TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
ImageButton btnReturn = new ImageButton(trdReturn);
btnReturn.setPosition(30, ALTO - 30 - btnReturn.getHeight());
// Click en boton Return
btnReturn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
main.setScreen(new PantallaMenu(main));
}
});
stageMenu.addActor(table);
stageMenu.addActor(btnReturn);
Gdx.input.setInputProcessor(stageMenu);
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.
the class PantallaTutorial method crearMainView.
private void crearMainView() {
stageMenu = new Stage(vista);
if (isHistory) {
imgBackground = new Texture("pantall_tutorial.png");
} else {
imgBackground = new Texture("pantall_tutorial2.png");
}
spriteBackground = new Sprite(imgBackground);
spriteBackground.setPosition(0, 0);
// spriteBackground.setAlpha(0.7f);
// Cuadro oscuro
/*Pixmap pixmap = new Pixmap((int)(ANCHO), (int)(ALTO), Pixmap.Format.RGBA8888 );
pixmap.setColor( 164/255f, 164/255f, 164/255f, 0.5f );
pixmap.fillRectangle(0, 0, pixmap.getWidth(), pixmap.getHeight());
Texture texturaRectangulo = new Texture( pixmap );
pixmap.dispose();
Image imgRectangulo = new Image(texturaRectangulo);
imgRectangulo.setPosition(0,0);*/
// Boton Return
TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
ImageButton btnReturn = new ImageButton(trdReturn);
btnReturn.setPosition(30, ALTO - 30 - btnReturn.getHeight());
// Click en boton Return
btnReturn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// Gdx.app.log("ClickListener","Si se clickeoooo");
main.setScreen(new PantallaMenu(main));
}
});
// stageMenu.addActor(imgRectangulo);
stageMenu.addActor(btnReturn);
Gdx.input.setInputProcessor(stageMenu);
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project libgdx by libgdx.
the class BaseG3dHudTest method createHUD.
protected void createHUD() {
hud = new Stage(new ScalingViewport(Scaling.fit, PREF_HUDWIDTH, PREF_HUDHEIGHT));
hudWidth = hud.getWidth();
hudHeight = hud.getHeight();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
final List<String> modelsList = new List(skin);
modelsList.setItems(models);
modelsList.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (!modelsWindow.isCollapsed() && getTapCount() == 2) {
onModelClicked(modelsList.getSelected());
modelsWindow.collapse();
}
}
});
modelsWindow = addListWindow("Models", modelsList, 0, -1);
fpsLabel = new Label("FPS: 999", skin);
hud.addActor(fpsLabel);
gridCheckBox = new CheckBox("Show grid", skin);
gridCheckBox.setChecked(showAxes);
gridCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
showAxes = gridCheckBox.isChecked();
}
});
gridCheckBox.setPosition(hudWidth - gridCheckBox.getWidth(), 0);
hud.addActor(gridCheckBox);
rotateCheckBox = new CheckBox("Rotate", skin);
rotateCheckBox.setChecked(true);
rotateCheckBox.setPosition(hudWidth - rotateCheckBox.getWidth(), gridCheckBox.getHeight());
hud.addActor(rotateCheckBox);
moveCheckBox = new CheckBox("Move", skin);
moveCheckBox.setChecked(false);
moveCheckBox.setPosition(hudWidth - moveCheckBox.getWidth(), rotateCheckBox.getTop());
hud.addActor(moveCheckBox);
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project libgdx by libgdx.
the class ControllersTest method setupUi.
private void setupUi() {
// setup a tiny ui with a console and a clear button.
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
stage = new Stage();
ui = new Table();
ui.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
console = new List(skin);
scrollPane = new ScrollPane(console);
scrollPane.setScrollbarsOnTop(true);
TextButton clear = new TextButton("Clear", skin);
ui.add(scrollPane).expand(true, true).fill();
ui.row();
ui.add(clear).expand(true, false).fill();
stage.addActor(ui);
clear.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
clear();
}
});
Gdx.input.setInputProcessor(stage);
}
Aggregations