Search in sources :

Example 6 with Label

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

the class BulletTestCollection method create.

@Override
public void create() {
    if (app == null) {
        app = Gdx.app;
        tests[testIndex].create();
    }
    cameraController = new CameraInputController(tests[testIndex].camera);
    cameraController.activateKey = Keys.CONTROL_LEFT;
    cameraController.autoUpdate = false;
    cameraController.forwardTarget = false;
    cameraController.translateTarget = false;
    Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this)));
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    hud = new Stage();
    hud.addActor(fpsLabel = new Label(" ", new Label.LabelStyle(font, Color.WHITE)));
    fpsLabel.setPosition(0, 0);
    hud.addActor(titleLabel = new Label(tests[testIndex].getClass().getSimpleName(), new Label.LabelStyle(font, Color.WHITE)));
    titleLabel.setY(hud.getHeight() - titleLabel.getHeight());
    hud.addActor(instructLabel = new Label("A\nB\nC\nD\nE\nF", new Label.LabelStyle(font, Color.WHITE)));
    instructLabel.setY(titleLabel.getY() - instructLabel.getHeight());
    instructLabel.setAlignment(Align.top | Align.left);
    instructLabel.setText(tests[testIndex].instructions);
}
Also used : CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) GestureDetector(com.badlogic.gdx.input.GestureDetector) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 7 with Label

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

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

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

the class Benchmark3DTest method create.

@Override
public void create() {
    super.create();
    GLProfiler.enable();
    randomizeLights();
    cam.position.set(10, 10, 10);
    cam.lookAt(0, 0, 0);
    cam.update();
    showAxes = true;
    lighting = true;
    vertexCountLabel = new Label("Vertices: 999", skin);
    vertexCountLabel.setPosition(0, fpsLabel.getTop());
    hud.addActor(vertexCountLabel);
    textureBindsLabel = new Label("Texture bindings: 999", skin);
    textureBindsLabel.setPosition(0, vertexCountLabel.getTop());
    hud.addActor(textureBindsLabel);
    shaderSwitchesLabel = new Label("Shader switches: 999", skin);
    shaderSwitchesLabel.setPosition(0, textureBindsLabel.getTop());
    hud.addActor(shaderSwitchesLabel);
    drawCallsLabel = new Label("Draw calls: 999", skin);
    drawCallsLabel.setPosition(0, shaderSwitchesLabel.getTop());
    hud.addActor(drawCallsLabel);
    glCallsLabel = new Label("GL calls: 999", skin);
    glCallsLabel.setPosition(0, drawCallsLabel.getTop());
    hud.addActor(glCallsLabel);
    lightsLabel = new Label("Lights: 999", skin);
    lightsLabel.setPosition(0, glCallsLabel.getTop());
    hud.addActor(lightsLabel);
    lightingCheckBox = new CheckBox("Lighting", skin);
    lightingCheckBox.setChecked(lighting);
    lightingCheckBox.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            lighting = lightingCheckBox.isChecked();
        }
    });
    lightingCheckBox.setPosition(hudWidth - lightingCheckBox.getWidth(), gridCheckBox.getTop());
    hud.addActor(lightingCheckBox);
    lightsCheckBox = new CheckBox("Randomize lights", skin);
    lightsCheckBox.setChecked(false);
    lightsCheckBox.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            lightsCheckBox.setChecked(false);
            randomizeLights();
        }
    });
    lightsCheckBox.setPosition(hudWidth - lightsCheckBox.getWidth(), lightingCheckBox.getTop());
    hud.addActor(lightsCheckBox);
    moveCheckBox.remove();
    rotateCheckBox.remove();
}
Also used : ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 10 with Label

use of com.badlogic.gdx.scenes.scene2d.ui.Label in project commons-gdx by gemserk.

the class Actors method topToast.

public static Actor topToast(final String text, final float time, final Skin skin) {
    final Window window = new Window("", skin);
    window.setMovable(false);
    window.defaults().spaceBottom(5);
    Label toastLabel = new Label(text, skin);
    toastLabel.setAlignment(Align.left);
    toastLabel.setWrap(true);
    window.row().fillX().expandX();
    window.add(toastLabel).fillX().padLeft(10);
    window.invalidate();
    window.setKeepWithinStage(false);
    window.setWidth(Gdx.graphics.getWidth() * 0.95f);
    window.setHeight(toastLabel.getTextBounds().height + 20 + window.getStyle().titleFont.getLineHeight());
    window.setX(Gdx.graphics.getWidth() * 0.5f - window.getWidth() * 0.5f);
    float outsideY = Gdx.graphics.getHeight() + window.getHeight();
    float insideY = Gdx.graphics.getHeight() - window.getHeight() + window.getStyle().titleFont.getLineHeight();
    window.setY(outsideY);
    final TimelineAnimation timelineAnimation = //
    Builders.animation(//
    Builders.timeline().value(//
    Builders.timelineValue(window, Scene2dConverters.actorPositionTypeConverter).keyFrame(//
    0f, //
    new float[] { window.getX(), outsideY }, InterpolationFunctions.linear(), //
    InterpolationFunctions.easeIn()).keyFrame(1f, //
    new float[] { window.getX(), insideY }).keyFrame(//
    4f, //
    new float[] { window.getX(), insideY }, InterpolationFunctions.linear(), //
    InterpolationFunctions.easeOut()).keyFrame(5f, //
    new float[] { window.getX(), outsideY }))).started(//
    true).delay(//
    0f).speed(//
    5f / time).build();
    window.addAction(new ActionAdapter() {

        @Override
        public boolean update(float delta) {
            timelineAnimation.update(delta);
            if (timelineAnimation.isFinished()) {
                window.remove();
                return true;
            }
            return false;
        }
    });
    return window;
}
Also used : Window(com.badlogic.gdx.scenes.scene2d.ui.Window) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TimelineAnimation(com.gemserk.animation4j.timeline.TimelineAnimation)

Aggregations

Label (com.badlogic.gdx.scenes.scene2d.ui.Label)43 Stage (com.badlogic.gdx.scenes.scene2d.Stage)25 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)24 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)23 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)20 Actor (com.badlogic.gdx.scenes.scene2d.Actor)18 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)16 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)16 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)10 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)10 Texture (com.badlogic.gdx.graphics.Texture)9 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)9 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)9 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)8 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)8 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)7 Window (com.badlogic.gdx.scenes.scene2d.ui.Window)7 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)6 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)5 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)5