use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class GroupTest method create.
public void create() {
batch = new SpriteBatch();
font = new BitmapFont();
renderer = new ShapeRenderer();
stage = new Stage(new ScreenViewport());
Gdx.input.setInputProcessor(stage);
region = new TextureRegion(new Texture(Gdx.files.internal("data/group-debug.png")));
group2 = new TestGroup("group2");
group2.setTransform(true);
stage.addActor(group2);
group1 = new TestGroup("group1");
group1.setTransform(true);
group2.addActor(group1);
LabelStyle style = new LabelStyle();
style.font = new BitmapFont();
Texture texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
horiz = new HorizontalGroup().pad(10, 20, 30, 40).top().space(5).reverse();
for (int i = 1; i <= 15; i++) {
horiz.addActor(new Label(i + ",", style));
if (i == 7)
horiz.addActor(new Container(new Image(texture)).size(10));
}
horiz.addActor(new Container(new Image(texture)).fill().prefSize(30));
horiz.debug();
horiz.setPosition(10, 10);
horiz.pack();
stage.addActor(horiz);
horizWrap = new HorizontalGroup().wrap().pad(10, 20, 30, 40).right().rowBottom().space(5).wrapSpace(15).reverse();
for (int i = 1; i <= 15; i++) {
horizWrap.addActor(new Label(i + ",", style));
if (i == 7)
horizWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
}
horizWrap.addActor(new Container(new Image(texture)).prefSize(30));
horizWrap.debug();
horizWrap.setBounds(10, 85, 150, 40);
stage.addActor(horizWrap);
vert = new VerticalGroup().pad(10, 20, 30, 40).top().space(5).reverse();
for (int i = 1; i <= 8; i++) {
vert.addActor(new Label(i + ",", style));
if (i == 4)
vert.addActor(new Container(new Image(texture)).size(10));
}
vert.addActor(new Container(new Image(texture)).size(30));
vert.debug();
vert.setPosition(515, 10);
vert.pack();
stage.addActor(vert);
vertWrap = new VerticalGroup().wrap().pad(10, 20, 30, 40).bottom().columnRight().space(5).wrapSpace(15).reverse();
for (int i = 1; i <= 8; i++) {
vertWrap.addActor(new Label(i + ",", style));
if (i == 4)
vertWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
}
vertWrap.addActor(new Container(new Image(texture)).prefSize(30));
vertWrap.debug();
vertWrap.setBounds(610, 10, 150, 40);
stage.addActor(vertWrap);
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class I18NMessageTest method create.
@Override
public void create() {
font = new BitmapFont();
batch = new SpriteBatch();
try {
FileHandle bfh = Gdx.files.internal("data/i18n/message1");
// Locale.ROOT doesn't exist in Android API level 8
rb_root = I18NBundle.createBundle(bfh, new Locale("", "", ""));
rb_default = I18NBundle.createBundle(bfh);
rb_en = I18NBundle.createBundle(bfh, new Locale("en", "US"));
rb_it = I18NBundle.createBundle(bfh, new Locale("it", "IT"));
rb_unsupported = I18NBundle.createBundle(bfh, new Locale("unsupported"));
println("Default locale: " + Locale.getDefault());
println("\n\n---- Parent chain test ----");
println(getMessage("root", rb_root));
println(getMessage("default", rb_default));
println(getMessage("en", rb_en));
println(getMessage("it", rb_it));
println(getMessage("unsupported", rb_unsupported));
println("\n\n---- Parametric message test ----");
println(getParametricMessage("root", rb_root));
println(getParametricMessage("default", rb_default));
println(getParametricMessage("en", rb_en));
println(getParametricMessage("it", rb_it));
println(getParametricMessage("unsupported", rb_unsupported));
Gdx.app.log("", message);
} catch (Throwable t) {
message = "FAILED: " + t.getMessage() + "\n";
message += t.getClass();
Gdx.app.error(I18NMessageTest.class.getSimpleName(), "Error", t);
}
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class I18NSimpleMessageTest method create.
@Override
public void create() {
font = new BitmapFont();
batch = new SpriteBatch();
I18NBundle.setSimpleFormatter(true);
try {
FileHandle bfh = Gdx.files.internal("data/i18n/message2");
// Locale.ROOT doesn't exist in Android API level 8
rb_root = I18NBundle.createBundle(bfh, new Locale("", "", ""));
rb_default = I18NBundle.createBundle(bfh);
rb_en = I18NBundle.createBundle(bfh, new Locale("en", "US"));
rb_it = I18NBundle.createBundle(bfh, new Locale("it", "IT"));
rb_unsupported = I18NBundle.createBundle(bfh, new Locale("unsupported"));
println("Default locale: " + Locale.getDefault());
println("\n\n---- Parent chain test ----");
println(getMessage("root", rb_root));
println(getMessage("default", rb_default));
println(getMessage("en", rb_en));
println(getMessage("it", rb_it));
println(getMessage("unsupported", rb_unsupported));
println("\n\n---- Parametric message test ----");
println(getParametricMessage("root", rb_root));
println(getParametricMessage("default", rb_default));
println(getParametricMessage("en", rb_en));
println(getParametricMessage("it", rb_it));
println(getParametricMessage("unsupported", rb_unsupported));
Gdx.app.log("", message);
} catch (Throwable t) {
message = "FAILED: " + t.getMessage() + "\n";
message += t.getClass();
Gdx.app.error(I18NSimpleMessageTest.class.getSimpleName(), "Error", t);
}
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class IntegerBitmapFontTest method create.
public void create() {
TextureAtlas textureAtlas = new TextureAtlas("data/pack");
font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), textureAtlas.findRegion("verdana39"), false);
singleLineCache = new BitmapFontCache(font, true);
multiLineCache = new BitmapFontCache(font, true);
singleLineCacheNonInteger = new BitmapFontCache(font, false);
multiLineCacheNonInteger = new BitmapFontCache(font, false);
batch = new SpriteBatch();
fillCaches();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch 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();
}
Aggregations