use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class TextAreaTest2 method create.
@Override
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
//Create a string that perfectly fills the float array used in the textarea float array
FloatArray dummyArray = new FloatArray();
String limit = "";
// Minus one, because TextField adds a magic char
for (int i = 0; i < dummyArray.items.length - 1; i++) {
limit += "a";
}
TextArea textArea = new TextArea(limit, skin);
textArea.setX(10);
textArea.setY(10);
textArea.setWidth(200);
textArea.setHeight(200);
stage.addActor(textArea);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class TextButtonTest method create.
@Override
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
for (int i = 0; i < 1; i++) {
TextButton t = new TextButton("Button" + i, skin);
t.setX(MathUtils.random(0, Gdx.graphics.getWidth()));
t.setY(MathUtils.random(0, Gdx.graphics.getHeight()));
t.setWidth(MathUtils.random(50, 200));
t.setHeight(MathUtils.random(0, 100));
stage.addActor(t);
}
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class TouchpadTest method create.
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
touchpad = new Touchpad(20, skin);
touchpad.setBounds(15, 15, 100, 100);
stage.addActor(touchpad);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class ImageTest method create.
@Override
public void create() {
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
image2 = new TextureRegion(new Texture(Gdx.files.internal("data/badlogic.jpg")));
ui = new Stage();
Gdx.input.setInputProcessor(ui);
root = new Table();
root.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
ui.addActor(root);
root.debug();
Image image = new Image(image2);
image.setScaling(Scaling.fill);
root.add(image).width(image2.getRegionWidth()).height(image2.getRegionHeight());
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class InterpolationTest method create.
@Override
public void create() {
Gdx.gl.glClearColor(.3f, .3f, .3f, 1);
renderer = new ShapeRenderer();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
stage = new Stage(new ScreenViewport());
resetPositions();
Field[] interpolationFields = ClassReflection.getFields(Interpolation.class);
// see how many fields are actually interpolations (for safety; other fields may be added with future)
int interpolationMembers = 0;
for (int i = 0; i < interpolationFields.length; i++) if (ClassReflection.isAssignableFrom(Interpolation.class, interpolationFields[i].getDeclaringClass()))
interpolationMembers++;
// get interpolation names
interpolationNames = new String[interpolationMembers];
for (int i = 0; i < interpolationFields.length; i++) if (ClassReflection.isAssignableFrom(Interpolation.class, interpolationFields[i].getDeclaringClass()))
interpolationNames[i] = interpolationFields[i].getName();
selectedInterpolation = interpolationNames[0];
list = new List(skin);
list.setItems(interpolationNames);
list.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
selectedInterpolation = list.getSelected();
time = 0;
resetPositions();
}
});
ScrollPane scroll = new ScrollPane(list, skin);
scroll.setFadeScrollBars(false);
scroll.setScrollingDisabled(true, false);
table = new Table();
table.setFillParent(true);
table.add(scroll).expandX().left().width(100);
stage.addActor(table);
Gdx.input.setInputProcessor(new InputMultiplexer(new InputAdapter() {
public boolean scrolled(int amount) {
if (!Gdx.input.isKeyPressed(Keys.CONTROL_LEFT))
return false;
duration -= amount / 15f;
duration = MathUtils.clamp(duration, 0, Float.POSITIVE_INFINITY);
return true;
}
}, stage, new InputAdapter() {
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (// if "walking" was interrupted by this touch down event
!Float.isNaN(time))
// set startPosition to the current position
startPosition.set(getPosition(time));
targetPosition.set(stage.screenToStageCoordinates(targetPosition.set(screenX, screenY)));
time = 0;
return true;
}
}));
}
Aggregations