Search in sources :

Example 51 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage in project TH902 by cn-s3bit.

the class GameMain method setScreen.

@Override
public void setScreen(Screen screen) {
    if (getScreen() != screen) {
        if (activeStage != null) {
            activeStage.dispose();
        }
        activeStage = new Stage();
        Entity.Reset();
    }
    super.setScreen(screen);
}
Also used : Stage(com.badlogic.gdx.scenes.scene2d.Stage)

Example 52 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage in project ProjektGG by eskalon.

the class BaseUIScreen method show.

@Override
public void show() {
    super.show();
    stage = new Stage(new ScreenViewport());
    mainTable = new Table();
    stage.addActor(mainTable);
    mainTable.setFillParent(true);
    mainTable.setDebug((boolean) game.showDebugStuff());
    game.getInputMultiplexer().addProcessor(stage);
    initUI();
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport)

Example 53 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage 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);
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) List(com.badlogic.gdx.scenes.scene2d.ui.List) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) ScalingViewport(com.badlogic.gdx.utils.viewport.ScalingViewport)

Example 54 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage 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 55 with Stage

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

the class ProgressBar method act.

@Override
public void act(float delta) {
    super.act(delta);
    if (animateTime > 0) {
        animateTime -= delta;
        Stage stage = getStage();
        if (stage != null && stage.getActionsRequestRendering())
            Gdx.graphics.requestRendering();
    }
}
Also used : Stage(com.badlogic.gdx.scenes.scene2d.Stage)

Aggregations

Stage (com.badlogic.gdx.scenes.scene2d.Stage)107 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)46 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)46 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)38 Texture (com.badlogic.gdx.graphics.Texture)36 Actor (com.badlogic.gdx.scenes.scene2d.Actor)32 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)30 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)30 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)28 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)22 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)22 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)20 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)19 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)18 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)15 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)13 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)12 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)11 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)10 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)10