Search in sources :

Example 91 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class DpiTest method create.

@Override
public void create() {
    font = new BitmapFont();
    batch = new SpriteBatch();
}
Also used : BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 92 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class ColorTest method create.

@Override
public void create() {
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    skin.add("default", new BitmapFont(Gdx.files.internal("data/arial-32.fnt"), false));
    Table root = new Table();
    stage.addActor(root);
    root.setFillParent(true);
    Table column1 = new Table(skin);
    column1.add("WHITE", "default", Color.WHITE).row();
    column1.add("LIGHT_GRAY", "default", Color.LIGHT_GRAY).row();
    column1.add("GRAY", "default", Color.GRAY).row();
    column1.add("DARK_GRAY", "default", Color.DARK_GRAY).row();
    column1.add("BLUE", "default", Color.BLUE).row();
    column1.add("NAVY", "default", Color.NAVY).row();
    column1.add("ROYAL", "default", Color.ROYAL).row();
    column1.add("SLATE", "default", Color.SLATE).row();
    column1.add("SKY", "default", Color.SKY).row();
    column1.add("CYAN", "default", Color.CYAN).row();
    column1.add("TEAL", "default", Color.TEAL).row();
    Table column2 = new Table(skin);
    column2.add("GREEN", "default", Color.GREEN).row();
    column2.add("CHARTREUSE", "default", Color.CHARTREUSE).row();
    column2.add("LIME", "default", Color.LIME).row();
    column2.add("FOREST", "default", Color.FOREST).row();
    column2.add("OLIVE", "default", Color.OLIVE).row();
    column2.add("YELLOW", "default", Color.YELLOW).row();
    column2.add("GOLD", "default", Color.GOLD).row();
    column2.add("GOLDENROD", "default", Color.GOLDENROD).row();
    column2.add("ORANGE", "default", Color.ORANGE).row();
    column2.add("BROWN", "default", Color.BROWN).row();
    column2.add("TAN", "default", Color.TAN).row();
    column2.add("FIREBRICK", "default", Color.FIREBRICK).row();
    Table column3 = new Table(skin);
    column3.add("RED", "default", Color.RED).row();
    column3.add("SCARLET", "default", Color.SCARLET).row();
    column3.add("CORAL", "default", Color.CORAL).row();
    column3.add("SALMON", "default", Color.SALMON).row();
    column3.add("PINK", "default", Color.PINK).row();
    column3.add("MAGENTA", "default", Color.MAGENTA).row();
    column3.add("PURPLE", "default", Color.PURPLE).row();
    column3.add("VIOLET", "default", Color.VIOLET).row();
    column3.add("MAROON", "default", Color.MAROON).row();
    root.add(column1);
    root.add(column2);
    root.add(column3);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 93 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class CullTest method create.

@Override
public void create() {
    ModelBuilder builder = new ModelBuilder();
    sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)), Usage.Position | Usage.Normal);
    // cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam = new OrthographicCamera(45, 45 * (Gdx.graphics.getWidth() / (float) Gdx.graphics.getHeight()));
    cam.near = 1;
    cam.far = 200;
    Random rand = new Random();
    for (int i = 0; i < instances.length; i++) {
        pos.set(rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * -100 - 3);
        instances[i] = new ModelInstance(sphere, pos);
    }
    modelBatch = new ModelBatch();
    batch = new SpriteBatch();
    font = new BitmapFont();
// Gdx.graphics.setVSync(true);
// Gdx.app.log("CullTest", "" + Gdx.graphics.getBufferFormat().toString());
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) Random(java.util.Random) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Material(com.badlogic.gdx.graphics.g3d.Material) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 94 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class VoxelTest method create.

@Override
public void create() {
    spriteBatch = new SpriteBatch();
    font = new BitmapFont();
    modelBatch = new ModelBatch();
    DefaultShader.defaultCullFace = GL20.GL_FRONT;
    camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.near = 0.5f;
    camera.far = 1000;
    controller = new FirstPersonCameraController(camera);
    Gdx.input.setInputProcessor(controller);
    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    lights.add(new DirectionalLight().set(1, 1, 1, 0, -1, 0));
    Texture texture = new Texture(Gdx.files.internal("data/g3d/tiles.png"));
    TextureRegion[][] tiles = TextureRegion.split(texture, 32, 32);
    MathUtils.random.setSeed(0);
    voxelWorld = new VoxelWorld(tiles[0], 20, 4, 20);
    PerlinNoiseGenerator.generateVoxels(voxelWorld, 0, 63, 10);
    float camX = voxelWorld.voxelsX / 2f;
    float camZ = voxelWorld.voxelsZ / 2f;
    float camY = voxelWorld.getHighest(camX, camZ) + 1.5f;
    camera.position.set(camX, camY, camZ);
}
Also used : DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Environment(com.badlogic.gdx.graphics.g3d.Environment) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) FirstPersonCameraController(com.badlogic.gdx.graphics.g3d.utils.FirstPersonCameraController) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 95 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class GwtTestWrapper method create.

@Override
public void create() {
    Gdx.app.setLogLevel(Application.LOG_DEBUG);
    Gdx.app.log("GdxTestGwt", "Setting up for " + tests.length + " tests.");
    ui = new Stage();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    container = new Table();
    ui.addActor(container);
    container.debug();
    Table table = new Table();
    ScrollPane scroll = new ScrollPane(table);
    container.add(scroll).expand().fill();
    table.pad(10).defaults().expandX().space(4);
    Arrays.sort(tests, new Comparator<Instancer>() {

        @Override
        public int compare(Instancer o1, Instancer o2) {
            return o1.instance().getClass().getName().compareTo(o2.instance().getClass().getName());
        }
    });
    for (final Instancer instancer : tests) {
        table.row();
        TextButton button = new TextButton(instancer.instance().getClass().getName(), skin);
        button.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                ((InputWrapper) Gdx.input).multiplexer.removeProcessor(ui);
                test = instancer.instance();
                Gdx.app.log("GdxTestGwt", "Clicked on " + test.getClass().getName());
                test.create();
                test.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            }
        });
        table.add(button).expandX().fillX();
    }
    container.row();
    container.add(new Label("Click on a test to start it, press ESC to close it.", new LabelStyle(font, Color.WHITE))).pad(5, 5, 5, 5);
    Gdx.input = new InputWrapper(Gdx.input) {

        @Override
        public boolean keyUp(int keycode) {
            if (keycode == Keys.ESCAPE) {
                if (test != null) {
                    Gdx.app.log("GdxTestGwt", "Exiting current test.");
                    dispose = true;
                }
            }
            return false;
        }

        @Override
        public boolean touchDown(int screenX, int screenY, int pointer, int button) {
            if (screenX < Gdx.graphics.getWidth() / 10.0 && screenY < Gdx.graphics.getHeight() / 10.0) {
                if (test != null) {
                    dispose = true;
                }
            }
            return false;
        }
    };
    ((InputWrapper) Gdx.input).multiplexer.addProcessor(ui);
    Gdx.app.log("GdxTestGwt", "Test picker UI setup complete.");
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)104 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)64 Texture (com.badlogic.gdx.graphics.Texture)31 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)21 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)18 Stage (com.badlogic.gdx.scenes.scene2d.Stage)16 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)13 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)12 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)11 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)10 Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)10 AssetManager (com.badlogic.gdx.assets.AssetManager)9 Color (com.badlogic.gdx.graphics.Color)8 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)8 InputAdapter (com.badlogic.gdx.InputAdapter)7 Actor (com.badlogic.gdx.scenes.scene2d.Actor)7 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)7 FileHandle (com.badlogic.gdx.files.FileHandle)6 Pixmap (com.badlogic.gdx.graphics.Pixmap)6 GlyphLayout (com.badlogic.gdx.graphics.g2d.GlyphLayout)6