use of com.badlogic.gdx.scenes.scene2d.ui.Table in project commons-gdx by gemserk.
the class DragBehaviorAction method update.
@Override
public boolean update(float delta) {
Table table = (Table) getActor();
worldTouchPosition.set(Gdx.input.getX(), Gdx.input.getY(), 1f);
table.getStage().getCamera().unproject(worldTouchPosition);
if (booleanMonitor.isChanged()) {
if (booleanMonitor.getValue())
previousPosition.set(worldTouchPosition.x, worldTouchPosition.y);
dragging = booleanMonitor.getValue();
}
if (dragging) {
drag.set(worldTouchPosition.x, worldTouchPosition.y);
drag.sub(previousPosition);
drag.x = Math.round(drag.x);
drag.y = Math.round(drag.y);
table.setX(table.getX() + drag.x);
table.setY(table.getY() + drag.y);
previousPosition.set(worldTouchPosition.x, worldTouchPosition.y);
}
return false;
}
use of com.badlogic.gdx.scenes.scene2d.ui.Table 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.ui.Table 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.ui.Table 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);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.
the class DragNDropTest method create.
@Override
public void create() {
BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR);
stage = new Stage();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
Gdx.input.setInputProcessor(stage);
root = new Table();
root.setFillParent(true);
root.align(Align.left | Align.top);
stage.addActor(root);
}
Aggregations