use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class ContainerTest method create.
@Override
public void create() {
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
stage = new Stage();
Gdx.input.setInputProcessor(stage);
TextureRegionDrawable logo = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("data/badlogic.jpg"))));
Table root = new Table();
root.setFillParent(true);
root.debug().defaults().space(6).size(110);
stage.addActor(root);
root.add(new Container(label("center")));
root.add(new Container(label("top")).top());
root.add(new Container(label("right")).right());
root.add(new Container(label("bottom")).bottom());
root.add(new Container(label("left")).left());
root.row();
root.add(new Container(label("fill")).fill());
root.add(new Container(label("fillX")).fillX());
root.add(new Container(label("fillY")).fillY());
root.add(new Container(label("fill 75%")).fill(0.75f, 0.75f));
root.add(new Container(label("fill 75% br")).fill(0.75f, 0.75f).bottom().right());
root.row();
root.add(new Container(label("padTop 5\ntop")).padTop(5).top());
root.add(new Container(label("padBottom 5\nbottom")).padBottom(5).bottom());
root.add(new Container(label("padLeft 15")).padLeft(15));
root.add(new Container(label("pad 10 fill")).pad(10).fill());
root.add(new Container(label("pad 10 tl")).pad(10).top().left());
root.row();
root.add(new Container(label("bg")).background(logo));
root.add(new Container(label("bg height 50")).background(logo).height(50));
Container transformBG = new Container(label("bg transform")).background(logo);
transformBG.setTransform(true);
transformBG.setOrigin(55, 55);
transformBG.rotateBy(90);
root.add(transformBG);
Container transform = new Container(label("transform"));
transform.setTransform(true);
transform.setOrigin(55, 55);
transform.rotateBy(90);
root.add(transform);
Container clip = new Container(label("clip1clip2clip3clip4"));
clip.setClip(true);
root.add(clip);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class DragAndDropTest method create.
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
final Skin skin = new Skin();
skin.add("default", new LabelStyle(new BitmapFont(), Color.WHITE));
skin.add("badlogic", new Texture("data/badlogic.jpg"));
Image sourceImage = new Image(skin, "badlogic");
sourceImage.setBounds(50, 125, 100, 100);
stage.addActor(sourceImage);
Image validTargetImage = new Image(skin, "badlogic");
validTargetImage.setBounds(200, 50, 100, 100);
stage.addActor(validTargetImage);
Image invalidTargetImage = new Image(skin, "badlogic");
invalidTargetImage.setBounds(200, 200, 100, 100);
stage.addActor(invalidTargetImage);
DragAndDrop dragAndDrop = new DragAndDrop();
dragAndDrop.addSource(new Source(sourceImage) {
public Payload dragStart(InputEvent event, float x, float y, int pointer) {
Payload payload = new Payload();
payload.setObject("Some payload!");
payload.setDragActor(new Label("Some payload!", skin));
Label validLabel = new Label("Some payload!", skin);
validLabel.setColor(0, 1, 0, 1);
payload.setValidDragActor(validLabel);
Label invalidLabel = new Label("Some payload!", skin);
invalidLabel.setColor(1, 0, 0, 1);
payload.setInvalidDragActor(invalidLabel);
return payload;
}
});
dragAndDrop.addTarget(new Target(validTargetImage) {
public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
getActor().setColor(Color.GREEN);
return true;
}
public void reset(Source source, Payload payload) {
getActor().setColor(Color.WHITE);
}
public void drop(Source source, Payload payload, float x, float y, int pointer) {
System.out.println("Accepted: " + payload.getObject() + " " + x + ", " + y);
}
});
dragAndDrop.addTarget(new Target(invalidTargetImage) {
public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
getActor().setColor(Color.RED);
return false;
}
public void reset(Source source, Payload payload) {
getActor().setColor(Color.WHITE);
}
public void drop(Source source, Payload payload, float x, float y, int pointer) {
}
});
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin 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.Skin 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.Skin in project libgdx by libgdx.
the class TextAreaTest method create.
@Override
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
TextArea textArea = new TextArea("Text Area\nEssentially, a text field\nwith\nmultiple\nlines.\n" + "It can even handle very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong lines.", skin);
textArea.setX(10);
textArea.setY(10);
textArea.setWidth(200);
textArea.setHeight(200);
TextField textField = new TextField("Text field", skin);
textField.setX(10);
textField.setY(220);
textField.setWidth(200);
textField.setHeight(30);
stage.addActor(textArea);
stage.addActor(textField);
}
Aggregations