Search in sources :

Example 1 with Container

use of com.badlogic.gdx.scenes.scene2d.ui.Container 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 2 with Container

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

the class GroupTest method create.

public void create() {
    batch = new SpriteBatch();
    font = new BitmapFont();
    renderer = new ShapeRenderer();
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    region = new TextureRegion(new Texture(Gdx.files.internal("data/group-debug.png")));
    group2 = new TestGroup("group2");
    group2.setTransform(true);
    stage.addActor(group2);
    group1 = new TestGroup("group1");
    group1.setTransform(true);
    group2.addActor(group1);
    LabelStyle style = new LabelStyle();
    style.font = new BitmapFont();
    Texture texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    horiz = new HorizontalGroup().pad(10, 20, 30, 40).top().space(5).reverse();
    for (int i = 1; i <= 15; i++) {
        horiz.addActor(new Label(i + ",", style));
        if (i == 7)
            horiz.addActor(new Container(new Image(texture)).size(10));
    }
    horiz.addActor(new Container(new Image(texture)).fill().prefSize(30));
    horiz.debug();
    horiz.setPosition(10, 10);
    horiz.pack();
    stage.addActor(horiz);
    horizWrap = new HorizontalGroup().wrap().pad(10, 20, 30, 40).right().rowBottom().space(5).wrapSpace(15).reverse();
    for (int i = 1; i <= 15; i++) {
        horizWrap.addActor(new Label(i + ",", style));
        if (i == 7)
            horizWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
    }
    horizWrap.addActor(new Container(new Image(texture)).prefSize(30));
    horizWrap.debug();
    horizWrap.setBounds(10, 85, 150, 40);
    stage.addActor(horizWrap);
    vert = new VerticalGroup().pad(10, 20, 30, 40).top().space(5).reverse();
    for (int i = 1; i <= 8; i++) {
        vert.addActor(new Label(i + ",", style));
        if (i == 4)
            vert.addActor(new Container(new Image(texture)).size(10));
    }
    vert.addActor(new Container(new Image(texture)).size(30));
    vert.debug();
    vert.setPosition(515, 10);
    vert.pack();
    stage.addActor(vert);
    vertWrap = new VerticalGroup().wrap().pad(10, 20, 30, 40).bottom().columnRight().space(5).wrapSpace(15).reverse();
    for (int i = 1; i <= 8; i++) {
        vertWrap.addActor(new Label(i + ",", style));
        if (i == 4)
            vertWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
    }
    vertWrap.addActor(new Container(new Image(texture)).prefSize(30));
    vertWrap.debug();
    vertWrap.setBounds(610, 10, 150, 40);
    stage.addActor(vertWrap);
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) VerticalGroup(com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) Stage(com.badlogic.gdx.scenes.scene2d.Stage) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Aggregations

Texture (com.badlogic.gdx.graphics.Texture)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 Stage (com.badlogic.gdx.scenes.scene2d.Stage)2 Container (com.badlogic.gdx.scenes.scene2d.ui.Container)2 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)1 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 LabelStyle (com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle)1 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 VerticalGroup (com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup)1 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)1 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)1