use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class StageDebugTest method create.
@Override
public void create() {
textureRegion = new TextureRegion(new Texture("data/badlogic.jpg"));
Gdx.input.setInputProcessor(this);
stage1 = new Stage();
stage1.getCamera().position.set(100, 100, 0);
Group group = new Group();
// group.setBounds(0, 0, 10, 10);
// group.setOrigin(25, 50);
group.setRotation(10);
group.setScale(1.2f);
stage1.addActor(group);
DebugActor actor = new DebugActor();
actor.setBounds(300, 140, 50, 100);
actor.setOrigin(25, 50);
actor.setRotation(-45);
actor.setScale(2f);
actor.addAction(forever(rotateBy(360, 8f)));
group.addActor(actor);
group.debugAll();
stage2 = new Stage();
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
TextButton shortButton = new TextButton("Button short", skin);
shortButton.debug();
TextButton longButton = new TextButton("Button loooooooooong", skin);
longButton.debug();
Table root = new Table(skin);
root.setFillParent(true);
root.setBackground(skin.getDrawable("default-pane"));
root.defaults().space(6);
root.setTransform(true);
root.rotateBy(10);
root.setScale(1.3f, 1);
root.debug();
stage2.addActor(root);
root.add(shortButton).pad(5);
root.add(longButton).row();
root.add("Colspan").colspan(2).row();
switchStage();
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class TableLayoutTest method create.
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
Label nameLabel = new Label("Name:", skin);
TextField nameText = new TextField("", skin);
Label addressLabel = new Label("Address:", skin);
TextField addressText = new TextField("", skin);
Table table = new Table();
stage.addActor(table);
table.setSize(260, 195);
table.setPosition(190, 142);
// table.align(Align.right | Align.bottom);
table.debug();
TextureRegion upRegion = skin.getRegion("default-slider-knob");
TextureRegion downRegion = skin.getRegion("default-slider-knob");
BitmapFont buttonFont = skin.getFont("default-font");
TextButton button = new TextButton("Button 1", skin);
button.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("touchDown 1");
return false;
}
});
table.add(button);
// table.setTouchable(Touchable.disabled);
Table table2 = new Table();
stage.addActor(table2);
table2.setFillParent(true);
table2.bottom();
TextButton button2 = new TextButton("Button 2", skin);
button2.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
System.out.println("2!");
}
});
button2.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("touchDown 2");
return false;
}
});
table2.add(button2);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class TableTest method create.
@Override
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
TextureRegion region = new TextureRegion(texture);
NinePatch patch = skin.getPatch("default-round");
Label label = new Label("This is some text.", skin);
root = new Table() {
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
}
};
stage.addActor(root);
// root.setTransform(true);
Table table = new Table();
table.setTransform(true);
table.setPosition(100, 100);
table.setOrigin(0, 0);
table.setRotation(45);
table.setScaleY(2);
table.add(label);
table.add(new TextButton("Text Button", skin));
table.pack();
// table.debug();
table.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
System.out.println("click!");
}
});
// root.addActor(table);
TextButton button = new TextButton("Text Button", skin);
Table table2 = new Table();
// table2.debug()
table2.add(button);
table2.setTransform(true);
table2.setScaleX(1.5f);
table2.setOrigin(table2.getPrefWidth() / 2, table2.getPrefHeight() / 2);
// Test colspan with expandX.
// root.setPosition(10, 10);
root.debug();
root.setFillParent(true);
root.add(new Label("meow meow meow meow meow meow meow meow meow meow meow meow", skin)).colspan(3).expandX();
root.add(new TextButton("Text Button", skin));
root.row();
root.add(new TextButton("Text Button", skin));
root.add(new TextButton("Toggle Button", skin.get("toggle", TextButtonStyle.class)));
root.add(new CheckBox("meow meow meow meow meow meow meow meow", skin));
// root.pack();
// root.add(new Button(new Image(region), skin));
// root.add(new LabelButton("Toggley", skin.getStyle("toggle", LabelButtonStyle.class)));
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin 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);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin 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);
}
Aggregations