Search in sources :

Example 36 with SpriteBatch

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);
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) VerticalGroup(com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) Stage(com.badlogic.gdx.scenes.scene2d.Stage) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 37 with SpriteBatch

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);
    }
}
Also used : Locale(java.util.Locale) FileHandle(com.badlogic.gdx.files.FileHandle) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 38 with SpriteBatch

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);
    }
}
Also used : Locale(java.util.Locale) FileHandle(com.badlogic.gdx.files.FileHandle) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 39 with SpriteBatch

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();
}
Also used : TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) BitmapFontCache(com.badlogic.gdx.graphics.g2d.BitmapFontCache)

Example 40 with SpriteBatch

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();
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Aggregations

SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)121 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)64 Texture (com.badlogic.gdx.graphics.Texture)59 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)32 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)22 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)16 Pixmap (com.badlogic.gdx.graphics.Pixmap)15 AssetManager (com.badlogic.gdx.assets.AssetManager)13 Stage (com.badlogic.gdx.scenes.scene2d.Stage)13 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)13 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)11 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)10 InputAdapter (com.badlogic.gdx.InputAdapter)9 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)9 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)8 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)7 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)7 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)7 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)7 Vector2 (com.badlogic.gdx.math.Vector2)7