Search in sources :

Example 41 with Table

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;
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table)

Example 42 with Table

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);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) ArrayList(java.util.ArrayList) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texto(mx.itesm.another_monkey_paradox.Utils.Texto) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Preferences(com.badlogic.gdx.Preferences) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 43 with Table

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);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) ArrayList(java.util.ArrayList) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texto(mx.itesm.another_monkey_paradox.Utils.Texto) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Preferences(com.badlogic.gdx.Preferences) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 44 with Table

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);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) List(com.badlogic.gdx.scenes.scene2d.ui.List) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 45 with Table

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);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Table (com.badlogic.gdx.scenes.scene2d.ui.Table)93 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)56 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)50 Stage (com.badlogic.gdx.scenes.scene2d.Stage)48 Actor (com.badlogic.gdx.scenes.scene2d.Actor)43 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)38 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)34 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)32 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)25 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)23 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)18 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)18 Texture (com.badlogic.gdx.graphics.Texture)17 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)14 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)14 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)13 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)13 SelectBox (com.badlogic.gdx.scenes.scene2d.ui.SelectBox)13 Button (com.badlogic.gdx.scenes.scene2d.ui.Button)12 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)12