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);
}
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();
}
}
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));
}
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();
}
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;
}
Aggregations