Search in sources :

Example 36 with Stage

use of com.badlogic.gdx.scenes.scene2d.Stage in project Entitas-Java by Rubentxu.

the class GameSceneState method loadResources.

@Override
public void loadResources() {
    this.skinManager = engine.getManager(SMGUIManager.class);
    this.assetsManager = engine.getManager(BaseAssetsManager.class);
    guiFactory = new GuiFactory(assetsManager, skin);
    bodyBuilder = new BodyBuilder();
    this.stage = new Stage();
    stage.clear();
    stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
    Gdx.input.setInputProcessor(stage);
    Gdx.app.log("Menu", "LoadResources");
    assetsManager.loadTextureAtlas(SPRITE_ATLAS);
    assetsManager.finishLoading();
}
Also used : Stage(com.badlogic.gdx.scenes.scene2d.Stage) GuiFactory(games.states.game.utils.GuiFactory) SMGUIManager(games.manager.SMGUIManager) BaseAssetsManager(com.ilargia.games.entitas.egdx.base.managers.BaseAssetsManager) BodyBuilder(ilargia.egdx.util.BodyBuilder)

Example 37 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 38 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 39 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)

Example 40 with Stage

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

the class TextField method next.

/** Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage.
	 * @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest. */
public void next(boolean up) {
    Stage stage = getStage();
    if (stage == null)
        return;
    TextField current = this;
    while (true) {
        current.getParent().localToStageCoordinates(tmp1.set(getX(), getY()));
        TextField textField = current.findNextTextField(stage.getActors(), null, tmp2, tmp1, up);
        if (textField == null) {
            // Try to wrap around.
            if (up)
                tmp1.set(Float.MIN_VALUE, Float.MIN_VALUE);
            else
                tmp1.set(Float.MAX_VALUE, Float.MAX_VALUE);
            textField = current.findNextTextField(getStage().getActors(), null, tmp2, tmp1, up);
        }
        if (textField == null) {
            Gdx.input.setOnscreenKeyboardVisible(false);
            break;
        }
        if (stage.setKeyboardFocus(textField))
            break;
        current = textField;
    }
}
Also used : Stage(com.badlogic.gdx.scenes.scene2d.Stage)

Aggregations

Stage (com.badlogic.gdx.scenes.scene2d.Stage)72 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)36 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)32 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)25 Texture (com.badlogic.gdx.graphics.Texture)24 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)20 Actor (com.badlogic.gdx.scenes.scene2d.Actor)19 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)18 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)16 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)16 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)15 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)14 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)13 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)13 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)9 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)8 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)6 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)5 Group (com.badlogic.gdx.scenes.scene2d.Group)5 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)4