use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class LabelScaleTest method create.
@Override
public void create() {
batch = new SpriteBatch();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Table table = new Table();
stage.addActor(table);
table.setPosition(200, 65);
Label label1 = new Label("This text is scaled 2x.", skin);
label1.setFontScale(2);
Label label2 = new Label("This text is scaled. This text is scaled. This text is scaled. This text is scaled. This text is scaled. ", skin);
label2.setWrap(true);
label2.setFontScale(0.75f, 0.75f);
table.debug();
table.add(label1);
table.row();
table.add(label2).fill();
table.pack();
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class TextAreaScrollTest method create.
@Override
public void create() {
stage = new Stage(new ScreenViewport());
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
Gdx.input.setInputProcessor(stage);
Table container = new Table();
stage.addActor(container);
container.setFillParent(true);
container.pad(10).defaults().expandX().fillX().space(4);
textArea = new TextArea(">>> FIRST LINE <<<\n" + "Scrolling to the bottom of the area you should see the last line.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Scrolling to the top of the area you should see the first line.\n" + ">>> LAST LINE <<<", skin) {
public float getPrefHeight() {
return getLines() * getStyle().font.getLineHeight();
}
};
scrollPane = new ScrollPane(textArea, skin);
scrollPane.setFadeScrollBars(false);
scrollPane.setFlickScroll(false);
container.row().height(350);
container.add(scrollPane);
container.debugAll();
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class MusicTest method create.
@Override
public void create() {
music = Gdx.audio.newMusic(Gdx.files.internal("data/8.12.mp3"));
music.play();
buttons = new TextureRegion(new Texture(Gdx.files.internal("data/playback.png")));
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
stage = new Stage();
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
slider = new Slider(0, 100, 0.1f, false, skin);
slider.setPosition(200, 20);
slider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (!sliderUpdating && slider.isDragging())
music.setPosition((slider.getValue() / 100f) * songDuration);
}
});
stage.addActor(slider);
Gdx.input.setInputProcessor(stage);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project libgdx by libgdx.
the class SoundTest method create.
@Override
public void create() {
sound = Gdx.audio.newSound(Gdx.files.getFileHandle("data/shotgun.ogg", FileType.Internal));
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
ui = new Stage();
TextButton play = new TextButton("Play", skin);
TextButton stop = new TextButton("Stop", skin);
final Slider pitch = new Slider(0.1f, 4, 0.1f, false, skin);
pitch.setValue(1);
final Label pitchValue = new Label("1.0", skin);
final Slider volume = new Slider(0.1f, 1, 0.1f, false, skin);
volume.setValue(1);
final Label volumeValue = new Label("1.0", skin);
Table table = new Table();
final Slider pan = new Slider(-1f, 1f, 0.1f, false, skin);
pan.setValue(0);
final Label panValue = new Label("0.0", skin);
table.setFillParent(true);
table.align(Align.center | Align.top);
table.columnDefaults(0).expandX().right().uniformX();
table.columnDefaults(2).expandX().left().uniformX();
table.add(play);
table.add(stop).left();
table.row();
table.add(new Label("Pitch", skin));
table.add(pitch);
table.add(pitchValue);
table.row();
table.add(new Label("Volume", skin));
table.add(volume);
table.add(volumeValue);
table.row();
table.add(new Label("Pan", skin));
table.add(pan);
table.add(panValue);
ui.addActor(table);
play.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
soundId = sound.play(volume.getValue());
sound.setPitch(soundId, pitch.getValue());
sound.setPan(soundId, pan.getValue(), volume.getValue());
}
});
stop.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
sound.stop(soundId);
}
});
pitch.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
sound.setPitch(soundId, pitch.getValue());
pitchValue.setText("" + pitch.getValue());
}
});
volume.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
sound.setVolume(soundId, volume.getValue());
volumeValue.setText("" + volume.getValue());
}
});
pan.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
sound.setPan(soundId, pan.getValue(), volume.getValue());
panValue.setText("" + pan.getValue());
}
});
Gdx.input.setInputProcessor(ui);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Skin in project Catacomb-Snatch by Catacomb-Snatch.
the class Art method loadResources.
/**
* Loads all the artwork
*
* @return True on success, otherwise false
*/
public static boolean loadResources() {
try {
// Load interface
skin = new Skin(Gdx.files.internal("art/interface.skin"), new TextureAtlas("art/interface.atlas"));
// Load backgrounds
pyramid = new TextureRegion(load("screen/pyramid.png"));
// Load characters
lordLard = cut("player/lord_lard.png", 32, 32);
// Load tiles
tiles_floor = cut("tiles/floor.png", 32, 32)[0];
tiles_sand = cut("tiles/sand.png", 32, 32)[0];
tiles_walls = cut("tiles/walls.png", 32, 56)[0];
tiles_shadows = cut("tiles/shadows.png", 32, 32)[0];
tiles_hole = cut("tiles/hole.png", 32, 32)[0];
// Load extras
logo = new TextureRegion(load("logo.png"));
return true;
} catch (Exception e) {
Gdx.app.error(TAG, "Something went wrong while loading a resource: ", e);
}
return false;
}
Aggregations