Search in sources :

Example 26 with BitmapFont

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

the class Box2DCharacterControllerTest method create.

@Override
public void create() {
    world = new World(new Vector2(0, -40), true);
    renderer = new Box2DDebugRenderer();
    cam = new OrthographicCamera(28, 20);
    createWorld();
    Gdx.input.setInputProcessor(this);
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
Also used : Box2DDebugRenderer(com.badlogic.gdx.physics.box2d.Box2DDebugRenderer) Vector2(com.badlogic.gdx.math.Vector2) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) World(com.badlogic.gdx.physics.box2d.World) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 27 with BitmapFont

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

the class Box2DTest method create.

@Override
public void create() {
    // setup the camera. In Box2D we operate on a
    // meter scale, pixels won't do it. So we use
    // an orthographic camera with a viewport of
    // 48 meters in width and 32 meters in height.
    // We also position the camera so that it
    // looks at (0,16) (that's where the middle of the
    // screen will be located).
    camera = new OrthographicCamera(48, 32);
    camera.position.set(0, 16, 0);
    // next we setup the immediate mode renderer
    renderer = new ShapeRenderer();
    // next we create the box2d debug renderer
    debugRenderer = new Box2DDebugRenderer();
    // next we create a SpriteBatch and a font
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    font.setColor(Color.RED);
    textureRegion = new TextureRegion(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
    // next we create out physics world.
    createPhysicsWorld();
    // register ourselfs as an InputProcessor
    Gdx.input.setInputProcessor(this);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Box2DDebugRenderer(com.badlogic.gdx.physics.box2d.Box2DDebugRenderer) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 28 with BitmapFont

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

the class BulletTestCollection method create.

@Override
public void create() {
    if (app == null) {
        app = Gdx.app;
        tests[testIndex].create();
    }
    cameraController = new CameraInputController(tests[testIndex].camera);
    cameraController.activateKey = Keys.CONTROL_LEFT;
    cameraController.autoUpdate = false;
    cameraController.forwardTarget = false;
    cameraController.translateTarget = false;
    Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this)));
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    hud = new Stage();
    hud.addActor(fpsLabel = new Label(" ", new Label.LabelStyle(font, Color.WHITE)));
    fpsLabel.setPosition(0, 0);
    hud.addActor(titleLabel = new Label(tests[testIndex].getClass().getSimpleName(), new Label.LabelStyle(font, Color.WHITE)));
    titleLabel.setY(hud.getHeight() - titleLabel.getHeight());
    hud.addActor(instructLabel = new Label("A\nB\nC\nD\nE\nF", new Label.LabelStyle(font, Color.WHITE)));
    instructLabel.setY(titleLabel.getY() - instructLabel.getHeight());
    instructLabel.setAlignment(Align.top | Align.left);
    instructLabel.setText(tests[testIndex].instructions);
}
Also used : CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) GestureDetector(com.badlogic.gdx.input.GestureDetector) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 29 with BitmapFont

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

the class BitmapFontAlignmentTest method create.

@Override
public void create() {
    Gdx.input.setInputProcessor(new InputAdapter() {

        public boolean touchDown(int x, int y, int pointer, int newParam) {
            renderMode = (renderMode + 1) % 6;
            return false;
        }
    });
    spriteBatch = new SpriteBatch();
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    logoSprite = new Sprite(texture);
    logoSprite.setColor(1, 1, 1, 0.6f);
    logoSprite.setBounds(50, 100, 400, 100);
    font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle("data/verdana39.png", FileType.Internal), false);
    cache = font.newFontCache();
    layout = new GlyphLayout();
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) InputAdapter(com.badlogic.gdx.InputAdapter) GlyphLayout(com.badlogic.gdx.graphics.g2d.GlyphLayout) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 30 with BitmapFont

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

the class BitmapFontFlipTest method create.

@Override
public void create() {
    Gdx.input.setInputProcessor(new InputAdapter() {

        public boolean touchDown(int x, int y, int pointer, int newParam) {
            renderMode = (renderMode + 1) % 4;
            return false;
        }
    });
    spriteBatch = new SpriteBatch();
    spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1));
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    logoSprite = new Sprite(texture);
    logoSprite.flip(false, true);
    logoSprite.setPosition(0, 320 - 256);
    logoSprite.setColor(1, 1, 1, 0.5f);
    font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true);
    cache1 = font.newFontCache();
    cache2 = font.newFontCache();
    cache3 = font.newFontCache();
    cache4 = font.newFontCache();
    cache5 = font.newFontCache();
    createCaches("cached", cache1, cache2, cache3, cache4, cache5);
    font.getData().setScale(1.33f);
    cacheScaled1 = font.newFontCache();
    cacheScaled2 = font.newFontCache();
    cacheScaled3 = font.newFontCache();
    cacheScaled4 = font.newFontCache();
    cacheScaled5 = font.newFontCache();
    createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5);
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) InputAdapter(com.badlogic.gdx.InputAdapter) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) Matrix4(com.badlogic.gdx.math.Matrix4)

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