Example usage for com.badlogic.gdx.graphics.g2d BitmapFont BitmapFont

List of usage examples for com.badlogic.gdx.graphics.g2d BitmapFont BitmapFont

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d BitmapFont BitmapFont.

Prototype

public BitmapFont() 

Source Link

Document

Creates a BitmapFont using the default 15pt Arial font included in the libgdx JAR file.

Usage

From source file:at.tugraz.ist.catroid.stage.StageListener.java

License:Open Source License

public void create() {

    font = new BitmapFont();
    font.setColor(1f, 0f, 0.05f, 1f);//w  w w .  j  a v a2 s .  co  m
    font.setScale(1.2f);

    pathForScreenshot = Utils.buildProjectPath(ProjectManager.getInstance().getCurrentProject().getName())
            + "/";

    costumeComparator = new CostumeComparator();

    project = ProjectManager.getInstance().getCurrentProject();

    virtualWidth = project.virtualScreenWidth;
    virtualHeight = project.virtualScreenHeight;

    virtualWidthHalf = virtualWidth / 2;
    virtualHeightHalf = virtualHeight / 2;

    screenMode = ScreenModes.STRETCH;

    stage = new Stage(virtualWidth, virtualHeight, true);
    batch = stage.getSpriteBatch();

    camera = (OrthographicCamera) stage.getCamera();
    camera.position.set(0, 0, 0);

    sprites = project.getSpriteList();
    for (Sprite sprite : sprites) {
        stage.addActor(sprite.costume);
    }
    if (DEBUG) {
        OrthoCamController camController = new OrthoCamController(camera);
        InputMultiplexer multiplexer = new InputMultiplexer();
        multiplexer.addProcessor(camController);
        multiplexer.addProcessor(stage);
        Gdx.input.setInputProcessor(multiplexer);
        fpsLogger = new FPSLogger();
    } else {
        Gdx.input.setInputProcessor(stage);
    }

    background = new Texture(Gdx.files.internal("stage/white_pixel.bmp"));
    axes = new Texture(Gdx.files.internal("stage/red_pixel.bmp"));
}

From source file:aurelienribon.texturepackergui.Canvas.java

License:Apache License

@Override
public void create() {
    Assets.loadAll();/*  w ww. ja  v a  2  s.  c  o  m*/
    Texture.setEnforcePotImages(false);

    batch = new SpriteBatch();
    font = new BitmapFont();
    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.update();

    infoLabel = new Sprite(Assets.getWhiteTex());
    infoLabel.setPosition(0, 0);
    infoLabel.setSize(140, 80);
    infoLabel.setColor(new Color(0x2A / 255f, 0x3B / 255f, 0x56 / 255f, 180 / 255f));

    int lblH = 25;
    Color lblC = new Color(0x2A / 255f, 0x6B / 255f, 0x56 / 255f, 180 / 255f);
    lblNextPage = new Label(10 + lblH, 120, lblH, "Next page", font, lblC, Anchor.TOP_RIGHT);
    lblPreviousPage = new Label(15 + lblH * 2, 120, lblH, "Previous page", font, lblC, Anchor.TOP_RIGHT);

    lblNextPage.setCallback(new Label.TouchCallback() {
        @Override
        public void touchDown(Label source) {
            nextPageRequested = true;
        }
    });

    lblPreviousPage.setCallback(new Label.TouchCallback() {
        @Override
        public void touchDown(Label source) {
            previousPageRequested = true;
        }
    });

    lblNextPage.show();
    lblPreviousPage.show();

    bgTex = Assets.getTransparentLightTex();
    bgTex.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);

    inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(new PanZoomInputProcessor(this));
    inputMultiplexer.addProcessor(buttonsInputProcessor);
    Gdx.input.setInputProcessor(inputMultiplexer);
}

From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.AbstractScreen.java

License:Open Source License

public BitmapFont getFont() {
    if (font == null) {
        font = new BitmapFont();
    }
    return font;
}

From source file:ch.coldpixel.mario.Scenes.Hud.java

public Hud(SpriteBatch sb) {
    worldTimer = 300;//from w w  w. j  ava 2 s. c o m
    timeCount = 0;
    score = 0;

    viewport = new FitViewport(MarioBros.V_WIDTH, MarioBros.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, sb);

    Table table = new Table();
    table.top(); //Top of our Stage
    table.setFillParent(true); //Table = size of our stage

    countdownLabel = new Label(String.format("%03d", worldTimer),
            new Label.LabelStyle(new BitmapFont(), Color.WHITE));//%03d = how many numbers, d=int,BitmapFont = Graphic Font, not regular Font
    scoreLabel = new Label(String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    marioLabel = new Label("MARIO", new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    table.add(marioLabel).expandX().padTop(10); //expandX = shares width with all elements, ex: 3 elements, each takes 1/3
    table.add(worldLabel).expandX().padTop(10);
    table.add(timeLabel).expandX().padTop(10);
    table.row();//New row
    table.add(scoreLabel).expandX();
    table.add(levelLabel).expandX();
    table.add(countdownLabel).expandX();

    stage.addActor(table);//Add table to Stage

}

From source file:com.axatrikx.solor.view.AbstractScreen.java

License:Apache License

public AbstractScreen(Solor game) {
    this.game = game;
    batch = new SpriteBatch();
    font = new BitmapFont();
}

From source file:com.badlogic.gdx.graphics.g3d.test.KeyframedModelViewer.java

License:Apache License

@Override
public void create() {
    model = ModelLoaderRegistry.loadKeyframedModel(Gdx.files.internal(fileName));
    if (textureFileName != null)
        texture = new Texture(Gdx.files.internal(textureFileName), Format.RGB565, true);
    model.setMaterial(new Material("default", new TextureAttribute(texture, 0, "skin")));
    hasNormals = hasNormals();//from  www  . j av a 2  s. c om
    anim = (KeyframedAnimation) model.getAnimations()[0];

    model.getBoundingBox(bounds);
    float len = bounds.getDimensions().len();
    System.out.println("bounds: " + bounds);

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(bounds.getCenter().cpy().add(len, len, len));
    cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z);
    cam.near = 1f;
    cam.far = 1000;

    renderer = new ImmediateModeRenderer10();
    batch = new SpriteBatch();
    font = new BitmapFont();
}

From source file:com.badlogic.gdx.graphics.g3d.test.QbobViewer.java

License:Apache License

@Override
public void create() {
    animModel = G3dtLoader.loadKeyframedModel(Gdx.files.internal("data/boy.g3dt"), true);
    anim = animModel.getAnimations()[0];
    Material material = new Material("default",
            new TextureAttribute(new Texture(Gdx.files.internal("data/boy.png")), 0, "tex0"));
    animModel.setMaterial(material);/*from ww  w .j a va2 s.c  om*/

    model[0] = G3dLoader.loadStillModel(Gdx.files.internal("data/qbob/test_section_01.dae.g3d"));
    lightMaps[0] = new Texture(Gdx.files.internal("data/qbob/world_blobbie_lm_01.jpg"), Format.RGB565, true);
    model[1] = G3dLoader.loadStillModel(Gdx.files.internal("data/qbob/test_section_02.dae.g3d"));
    lightMaps[1] = new Texture(Gdx.files.internal("data/qbob/world_blobbie_lm_02.jpg"), Format.RGB565, true);
    model[2] = G3dLoader.loadStillModel(Gdx.files.internal("data/qbob/test_section_03.dae.g3d"));
    lightMaps[2] = new Texture(Gdx.files.internal("data/qbob/world_blobbie_lm_03.jpg"), Format.RGB565, true);
    model[3] = G3dLoader.loadStillModel(Gdx.files.internal("data/qbob/test_section_04.dae.g3d"));
    lightMaps[3] = new Texture(Gdx.files.internal("data/qbob/world_blobbie_lm_04.jpg"), Format.RGB565, true);

    diffuse = new Texture(Gdx.files.internal("data/qbob/world_blobbie_blocks.png"), Format.RGB565, true);

    cam = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(30, 10, 85f);
    cam.direction.set(0, 0, -1);
    cam.up.set(0, 1, 0);
    cam.near = 10f;
    cam.far = 1000;

    controller = new PerspectiveCamController(cam);
    Gdx.input.setInputProcessor(controller);

    batch = new SpriteBatch();
    font = new BitmapFont();
}

From source file:com.badlogic.gdx.graphics.g3d.test.SkeletonModelViewer.java

License:Apache License

@Override
public void create() {
    if (fileName.endsWith(".xml")) {
        model = new OgreXmlLoader().load(Gdx.files.internal(fileName),
                Gdx.files.internal(fileName.replace("mesh.xml", "skeleton.xml")));
    } else//from   w ww  .j  a v a 2s. c  o m
        throw new GdxRuntimeException("Unknown file format '" + fileName + "'");
    if (textureFileName != null)
        texture = new Texture(Gdx.files.internal(textureFileName));
    hasNormals = hasNormals();
    Material material = new Material("material", new TextureAttribute(texture, 0, "s_tex"));
    model.setMaterial(material);
    anim = (SkeletonAnimation) model.getAnimations()[0];

    model.getBoundingBox(bounds);
    float len = bounds.getDimensions().len();
    System.out.println("bounds: " + bounds);

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(bounds.getCenter().cpy().add(len, len, len));
    cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z);
    cam.near = 1f;
    cam.far = 1000;

    renderer = new ImmediateModeRenderer10();
    batch = new SpriteBatch();
    font = new BitmapFont();
}

From source file:com.badlogic.gdx.graphics.g3d.test.StillModelViewer.java

License:Apache License

@Override
public void create() {
    long start = System.nanoTime();
    model = ModelLoaderRegistry.loadStillModel(Gdx.files.internal(fileName));
    Gdx.app.log("StillModelViewer", "loading took: " + (System.nanoTime() - start) / 1000000000.0f);

    for (StillSubMesh mesh : model.subMeshes) {
        mesh.mesh.scale(0.1f, 0.1f, 0.1f);
    }/* w ww  . ja v a 2s.co m*/

    if (!fileName.endsWith(".g3d")) {
        G3dExporter.export(model, Gdx.files.absolute(fileName + ".g3d"));
        start = System.nanoTime();
        model = G3dLoader.loadStillModel(Gdx.files.absolute(fileName + ".g3d"));
        Gdx.app.log("StillModelViewer", "loading binary took: " + (System.nanoTime() - start) / 1000000000.0f);
    }

    if (textureFileNames.length != 0) {
        textures = new Texture[textureFileNames.length];
        for (int i = 0; i < textureFileNames.length; i++) {
            textures[i] = new Texture(Gdx.files.internal(textureFileNames[i]), i > 0 ? false : true);
        }
    }
    hasNormals = hasNormals();

    model.getBoundingBox(bounds);
    float len = bounds.getDimensions().len();
    System.out.println("bounds: " + bounds);

    cam = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(bounds.getCenter().cpy().add(len / 2, len / 2, len / 2));
    cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z);
    cam.near = 0.1f;
    cam.far = 1000;

    renderer = new ImmediateModeRenderer10();
    batch = new SpriteBatch();
    font = new BitmapFont();
}

From source file:com.badlogic.gdx.graphics.g3d.test.StillModelViewerGL20.java

License:Apache License

@Override
public void create() {
    long start = System.nanoTime();
    model = ModelLoaderRegistry.loadStillModel(Gdx.files.internal(fileName));
    Gdx.app.log("StillModelViewer", "loading took: " + (System.nanoTime() - start) / 1000000000.0f);

    if (textureFileNames.length != 0) {
        textures = new Texture[textureFileNames.length];
        for (int i = 0; i < textureFileNames.length; i++) {
            textures[i] = new Texture(Gdx.files.internal(textureFileNames[i]), i > 0 ? false : true);
        }/*from   ww w.  j av  a2s  . c  o  m*/
    }

    model.getBoundingBox(bounds);
    float len = bounds.getDimensions().len();
    System.out.println("bounds: " + bounds);

    cam = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(bounds.getCenter().cpy().add(len / 2, len / 2, len / 2));
    cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z);
    cam.near = 0.1f;
    cam.far = 64;

    batch = new SpriteBatch();
    font = new BitmapFont();

    // shader1 = ShaderLoader.createShader("light", "light");
    // shader2 = ShaderLoader.createShader("vertexpath", "vertexpath");

    lightManager = new LightManager(4, LightQuality.VERTEX);
    lightManager.dirLight = new DirectionalLight();
    lightManager.dirLight.color.set(0.09f, 0.07f, 0.09f, 0);
    lightManager.dirLight.direction.set(-.4f, -1, 0.03f).nor();

    for (int i = 0; i < 4; i++) {
        PointLight l = new PointLight();
        l.position.set(-MathUtils.random(8) + 4, MathUtils.random(3), -MathUtils.random(6) + 3);

        l.color.r = MathUtils.random();
        l.color.b = MathUtils.random();
        l.color.g = MathUtils.random();
        l.intensity = 3;
        lightManager.addLigth(l);
    }
    lightManager.ambientLight.set(.03f, 0.05f, 0.06f, 0);

    protoRenderer = new PrototypeRendererGL20(lightManager);
    protoRenderer.cam = cam;

    MaterialAttribute c1 = new ColorAttribute(new Color(0.5f, 0.51f, 0.51f, 1.0f), ColorAttribute.specular);
    MaterialAttribute c2 = new ColorAttribute(new Color(0.95f, 0.95f, 0.95f, 1.0f), ColorAttribute.diffuse);
    MaterialAttribute t0 = new TextureAttribute(textures[0], 0, TextureAttribute.diffuseTexture);
    Material material = new Material("basic", c1, c2, t0);

    model.setMaterial(material);
    instance = new StillModelNode();
    instance.getTransform().translate(-len / 2, -1, 2);
    instance.radius = bounds.getDimensions().len() / 2;

    instance2 = new StillModelNode();
    instance2.getTransform().translate(len / 2, -1, -7);

    instance2.radius = instance.radius;

}