Example usage for com.badlogic.gdx.scenes.scene2d.ui Label Label

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Label Label

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui Label Label.

Prototype

Label

Source Link

Usage

From source file:es.eucm.ead.editor.control.actions.editor.AddLabel.java

License:Open Source License

@Override
public void input(String text) {
    if (text != null && !text.replace(" ", "").isEmpty()) {
        Label label = new Label();
        label.setText(text);/*w  ww  .j  av  a  2s .c om*/
        addText(label, false);
    }
}

From source file:es.eucm.ead.engine.systems.conversations.LineSystem.java

License:Open Source License

public Actor buildLineActor(LineComponent line) {
    LabelStyle labelStyle = gameAssets.getSkin().get("bubble", LabelStyle.class);

    BitmapFont font = labelStyle.font;//  w w  w .  java  2s. c  o m
    float width = Math.max(1, gameView.getWorldWidth()
            - (labelStyle.background == null ? 0 : labelStyle.background.getMinHeight()));
    Array<String> lines = EngineUtils.lines(gameAssets.getI18N().m(line.getLine()), width, font);

    ModelEntity group = new ModelEntity();

    EmptyRenderer area = new EmptyRenderer();
    area.setHitAll(true);
    group.getComponents().add(area);

    Behavior behavior = new Behavior();
    behavior.setEvent(new Touch());

    ChangeVar changeVar = new ChangeVar();
    changeVar.setVariable(LineRuntimeNode.getLineEndedVar(line.getConversation()));
    changeVar.setExpression("btrue");
    behavior.getEffects().add(changeVar);
    behavior.getEffects().add(new RemoveEntity());
    group.getComponents().add(behavior);

    ModelEntity bubble = new ModelEntity();

    VerticalLayout verticalLayout = new VerticalLayout();
    if (line.getSpeaker() != null && !"".equals(line.getSpeaker())) {
        Label speakerLabel = new Label();
        speakerLabel.setText(line.getSpeaker());
        speakerLabel.setStyle("speaker");
        verticalLayout.getControls().add(speakerLabel);
    }

    Label linesLabel = new Label();
    String linesText = "";
    for (String l : lines) {
        linesText += l + "\n";
    }
    linesLabel.setText(linesText);
    linesLabel.setStyle("bubble");

    verticalLayout.getControls().add(linesLabel);

    bubble.getComponents().add(verticalLayout);
    bubble.setX(0);
    bubble.setY(0);

    group.getChildren().add(bubble);

    EngineEntity engineEntity = entitiesLoader.toEngineEntity(group);
    return engineEntity.getGroup();
}