Search in sources :

Example 11 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.

the class ContainerTest method create.

@Override
public void create() {
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    TextureRegionDrawable logo = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("data/badlogic.jpg"))));
    Table root = new Table();
    root.setFillParent(true);
    root.debug().defaults().space(6).size(110);
    stage.addActor(root);
    root.add(new Container(label("center")));
    root.add(new Container(label("top")).top());
    root.add(new Container(label("right")).right());
    root.add(new Container(label("bottom")).bottom());
    root.add(new Container(label("left")).left());
    root.row();
    root.add(new Container(label("fill")).fill());
    root.add(new Container(label("fillX")).fillX());
    root.add(new Container(label("fillY")).fillY());
    root.add(new Container(label("fill 75%")).fill(0.75f, 0.75f));
    root.add(new Container(label("fill 75% br")).fill(0.75f, 0.75f).bottom().right());
    root.row();
    root.add(new Container(label("padTop 5\ntop")).padTop(5).top());
    root.add(new Container(label("padBottom 5\nbottom")).padBottom(5).bottom());
    root.add(new Container(label("padLeft 15")).padLeft(15));
    root.add(new Container(label("pad 10 fill")).pad(10).fill());
    root.add(new Container(label("pad 10 tl")).pad(10).top().left());
    root.row();
    root.add(new Container(label("bg")).background(logo));
    root.add(new Container(label("bg height 50")).background(logo).height(50));
    Container transformBG = new Container(label("bg transform")).background(logo);
    transformBG.setTransform(true);
    transformBG.setOrigin(55, 55);
    transformBG.rotateBy(90);
    root.add(transformBG);
    Container transform = new Container(label("transform"));
    transform.setTransform(true);
    transform.setOrigin(55, 55);
    transform.rotateBy(90);
    root.add(transform);
    Container clip = new Container(label("clip1clip2clip3clip4"));
    clip.setClip(true);
    root.add(clip);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) Texture(com.badlogic.gdx.graphics.Texture)

Example 12 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.

the class GroupCullingTest method create.

public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    root = new Table();
    root.setFillParent(true);
    stage.addActor(root);
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    Table labels = new Table();
    root.add(new ScrollPane(labels, skin)).expand().fill();
    root.row();
    root.add(drawnLabel = new Label("", skin));
    for (int i = 0; i < count; i++) {
        labels.add(new Label("Label: " + i, skin) {

            public void draw(Batch batch, float parentAlpha) {
                super.draw(batch, parentAlpha);
                drawn++;
            }
        });
        labels.row();
    }
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Batch(com.badlogic.gdx.graphics.g2d.Batch) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 13 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.

the class ViewportTest1 method create.

public void create() {
    stage = new Stage();
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    label = new Label("", skin);
    Table root = new Table(skin);
    root.setFillParent(true);
    root.setBackground(skin.getDrawable("default-pane"));
    root.debug().defaults().space(6);
    root.add(new TextButton("Button 1", skin));
    root.add(new TextButton("Button 2", skin)).row();
    root.add("Press spacebar to change the viewport:").colspan(2).row();
    root.add(label).colspan(2);
    stage.addActor(root);
    viewports = getViewports(stage.getCamera());
    names = getViewportNames();
    stage.setViewport(viewports.first());
    label.setText(names.first());
    Gdx.input.setInputProcessor(new InputMultiplexer(new InputAdapter() {

        public boolean keyDown(int keycode) {
            if (keycode == Input.Keys.SPACE) {
                int index = (viewports.indexOf(stage.getViewport(), true) + 1) % viewports.size;
                label.setText(names.get(index));
                Viewport viewport = viewports.get(index);
                stage.setViewport(viewport);
                resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            }
            return false;
        }
    }, stage));
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) InputAdapter(com.badlogic.gdx.InputAdapter) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) StretchViewport(com.badlogic.gdx.utils.viewport.StretchViewport) ExtendViewport(com.badlogic.gdx.utils.viewport.ExtendViewport) ScalingViewport(com.badlogic.gdx.utils.viewport.ScalingViewport) FitViewport(com.badlogic.gdx.utils.viewport.FitViewport) Viewport(com.badlogic.gdx.utils.viewport.Viewport) FillViewport(com.badlogic.gdx.utils.viewport.FillViewport) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 14 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"));
    Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
    String names = prefs.getString("names", null);
    if (names == null) {
        // prefs.putString("names", "Astro");
        names = "Astro,";
    }
    String scores = prefs.getString("highscores", null);
    if (scores == null) {
        // prefs.putString("highscores", "10000");
        scores = "10000,";
    }
    Table table = new Table(skin);
    table.defaults().pad(10f);
    table.setFillParent(true);
    table.setPosition(table.getX(), table.getY() + 250);
    /**
     * Se hace el titulo de scores
     */
    // Label scoresTitle = new Label("HIGHSCORES STORY MODE", skin);
    // scoresTitle.setFontScale(4f,4f);
    // scoresTitle.setAlignment(Align.center);
    /**
     * Se crean las columnas con puntuajes
     */
    Label columnName;
    Label columnScore;
    String[] allScores = scores.split(",");
    String[] allNames = names.split(",");
    int i = 0;
    // table.add(scoresTitle).colspan(2).fillX().height(150);
    table.row();
    for (String name : allNames) {
        columnName = new Label(name + ": ", skin);
        columnName.setFontScale(3f, 3f);
        table.add(columnName);
        columnScore = new Label(allScores[i], skin);
        columnScore.setFontScale(3f, 3f);
        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) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) 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 15 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project skin-composer by raeleus.

the class RootTable method addStyleAndPreviewSplit.

private void addStyleAndPreviewSplit() {
    stylePropertiesTable = new Table();
    stylePropertiesTable.setTouchable(Touchable.enabled);
    addStyleProperties(stylePropertiesTable);
    Table right = new Table();
    right.setTouchable(Touchable.enabled);
    addPreviewPreviewPropertiesSplit(right, scrollPaneListener);
    SplitPane splitPane = new SplitPane(stylePropertiesTable, right, false, getSkin());
    add(splitPane).grow();
    splitPane.addListener(new InputListener() {

        @Override
        public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
            if (!draggingCursor && event.getListenerActor().equals(event.getTarget())) {
                Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow);
            }
        }

        @Override
        public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
            if (!draggingCursor && event.getListenerActor().equals(event.getTarget())) {
                Gdx.graphics.setSystemCursor(Cursor.SystemCursor.HorizontalResize);
            }
        }
    });
    splitPane.addListener(new DragListener() {

        @Override
        public void dragStop(InputEvent event, float x, float y, int pointer) {
            Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow);
            draggingCursor = false;
        }

        @Override
        public void dragStart(InputEvent event, float x, float y, int pointer) {
            if (!draggingCursor && event.getListenerActor().equals(event.getTarget())) {
                Gdx.graphics.setSystemCursor(Cursor.SystemCursor.HorizontalResize);
                draggingCursor = true;
            }
        }
    });
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) DragListener(com.badlogic.gdx.scenes.scene2d.utils.DragListener) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SplitPane(com.badlogic.gdx.scenes.scene2d.ui.SplitPane) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

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