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(FileHandle fontFile) 

Source Link

Document

Creates a BitmapFont from a BMFont file.

Usage

From source file:awakening.view.menu.MainMenu.java

License:Apache License

/**
 * Constructor//  w w w  . ja v  a2s  .c o m
 * 
 * @param game Tower Awakening's Game
 */
public MainMenu(TAGame game) {
    super();
    this.game = game;
    this.music = Gdx.audio.newMusic(Gdx.files.internal("sound/menu/Dark Intro_0.ogg"));
    effect = Gdx.audio.newSound(Gdx.files.internal("sound/widget/Button Sound 53.wav"));
    stage = new Stage();

    ///Language
    try {
        if (game.getLanguage().equals("ENGLISH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]);
        } else if (game.getLanguage().equals("FRENCH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]);
        } else if (game.getLanguage().equals("ITALIAN")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]);
        } else {
            language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]);
        }
    } catch (java.util.MissingResourceException e) {
        System.out.println("yolo");
    }

    ///Viewport
    camera = new OrthographicCamera();
    view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera);

    ///Background
    background = new Texture(Gdx.files.internal("img/menu/background-menu.png"));
    batch = new SpriteBatch();

    ///Skin
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    font = new BitmapFont(Gdx.files.internal("font/space.fnt"));
    style = new LabelStyle(font, Color.WHITE);

    ///Title
    title = new Label(language.getString("label_main_title"), skin);
    title.setStyle(style);

    ///Widgets Background
    widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/bg widgets.png")));

    ///Exit Button
    btnExit = new TextButton(language.getString("button_exit"), skin);

    ///Options Button
    btnOptions = new TextButton(language.getString("button_options"), skin);

    ///Multiplayer Button
    btnMultiplayer = new TextButton(language.getString("button_multiplayer"), skin);

    ///Solo Button
    btnSolo = new TextButton(language.getString("button_solo"), skin);

}

From source file:awakening.view.menu.MainMenu.java

License:Apache License

/**
 * Constructor/*  www  . j a  v  a  2  s  . c o m*/
 * 
 * @param game Tower Awakening's Game
 * @param sound Main menu's music
 * @param effect Button's effect
 */
public MainMenu(TAGame game, Music sound, Sound effect) {
    this.game = game;
    this.music = sound;
    this.effect = effect;
    stage = new Stage();

    ///Language
    try {
        if (game.getLanguage().equals("ENGLISH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]);
        } else if (game.getLanguage().equals("FRENCH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]);
        } else if (game.getLanguage().equals("ITALIAN")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]);
        } else {
            language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]);
        }
    } catch (java.util.MissingResourceException e) {
        System.out.println("yolo");
    }

    ///Viewport
    camera = new OrthographicCamera();
    view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera);

    ///Background
    background = new Texture(Gdx.files.internal("img/menu/background-menu.png"));
    batch = new SpriteBatch();

    ///Skin
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    font = new BitmapFont(Gdx.files.internal("font/space.fnt"));
    style = new LabelStyle(font, Color.WHITE);

    ///Title
    title = new Label(language.getString("label_main_title"), skin);
    title.setStyle(style);

    ///Widgets Background
    widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/bg widgets.png")));

    ///Exit Button
    btnExit = new TextButton(language.getString("button_exit"), skin);

    ///Options Button
    btnOptions = new TextButton(language.getString("button_options"), skin);

    ///Multiplayer Button
    btnMultiplayer = new TextButton(language.getString("button_multiplayer"), skin);

    ///Solo Button
    btnSolo = new TextButton(language.getString("button_solo"), skin);
}

From source file:cmnworks.com.angrybee.Display.java

License:Open Source License

public void ready() {
    font = new BitmapFont(Gdx.files.internal(setFontName));
}

From source file:com.arnopaja.supermac.helpers.load.AssetLoader.java

License:Creative Commons License

public static void load() {

    tilesTexture = new Texture(getHandle("canvas/landscape_tiles.png"));
    tilesTexture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);

    //--------------------------
    //          Tiles
    //--------------------------

    treeBig = SpriteUtils.makeSprite(tilesTexture, 0, 0, 2, 2);
    treeSmall = SpriteUtils.makeSprite(tilesTexture, 2, 0);
    grass0 = SpriteUtils.makeSprite(tilesTexture, 3, 0);
    grass1 = SpriteUtils.makeSprite(tilesTexture, 4, 0);
    grass2 = SpriteUtils.makeSprite(tilesTexture, 5, 0);
    bush = SpriteUtils.makeSprite(tilesTexture, 6, 0);
    bushH = SpriteUtils.makeSprite(tilesTexture, 7, 0);
    bushFlowersH = SpriteUtils.makeSprite(tilesTexture, 8, 0);
    bushV = SpriteUtils.makeSprite(tilesTexture, 9, 0);
    bushFlowersV = SpriteUtils.makeSprite(tilesTexture, 10, 0);

    sidewalk = SpriteUtils.makeSprite(tilesTexture, 11, 0);
    cobbleRed = SpriteUtils.makeSprite(tilesTexture, 0, 2);
    cobble = SpriteUtils.makeSprite(tilesTexture, 1, 2);

    asphalt = SpriteUtils.makeSprite(tilesTexture, 5, 4);
    asphaltGrassE = SpriteUtils.makeSprite(tilesTexture, 0, 3);
    asphaltGrassW = SpriteUtils.makeSprite(tilesTexture, 0, 3, false, true);
    asphaltGrassN = SpriteUtils.makeSprite(tilesTexture, 0, 4);
    asphaltGrassS = SpriteUtils.makeSprite(tilesTexture, 0, 4, true, false);
    asphaltGrassNE = SpriteUtils.makeSprite(tilesTexture, 2, 3);
    asphaltGrassSE = SpriteUtils.makeSprite(tilesTexture, 2, 3, true, false);
    asphaltGrassSW = SpriteUtils.makeSprite(tilesTexture, 2, 3, true, true);
    asphaltGrassNW = SpriteUtils.makeSprite(tilesTexture, 2, 3, false, true);
    asphaltLineH = SpriteUtils.makeSprite(tilesTexture, 4, 3);
    asphaltLineV = SpriteUtils.makeSprite(tilesTexture, 4, 4);
    asphaltCobbleE = SpriteUtils.makeSprite(tilesTexture, 6, 3, false, true);
    asphaltCobbleW = SpriteUtils.makeSprite(tilesTexture, 6, 3);
    asphaltCobbleN = SpriteUtils.makeSprite(tilesTexture, 5, 3);
    asphaltCobbleS = SpriteUtils.makeSprite(tilesTexture, 5, 3, true, false);
    asphaltCobbleNE = SpriteUtils.makeSprite(tilesTexture, 6, 4, false, true);
    asphaltCobbleSE = SpriteUtils.makeSprite(tilesTexture, 6, 4, true, true);
    asphaltCobbleSW = SpriteUtils.makeSprite(tilesTexture, 6, 4, true, false);
    asphaltCobbleNW = SpriteUtils.makeSprite(tilesTexture, 6, 4);

    TextureRegion[] temp = new TextureRegion[12];
    for (int i = 0; i < 7; i++) {
        temp[i] = SpriteUtils.makeSprite(tilesTexture, 17 + 3 * i, 0, 3, 3);
        if (i != 0) {
            temp[12 - i] = temp[i];//from  www.j ava2 s  .  c  o m
        }
    }
    asteroid = new Animation(0.5f, temp);

    //--------------------------
    //        Buildings
    //--------------------------

    weyerhauser = SpriteUtils.makeSprite(tilesTexture, 0, 5, 24, 12);
    campusCenter = SpriteUtils.makeSprite(tilesTexture, 24, 5, 20, 16);
    chapel = SpriteUtils.makeSprite(tilesTexture, 44, 5, 14, 16);
    kirk = SpriteUtils.makeSprite(tilesTexture, 58, 29, 32, 16);
    leonardCenter = SpriteUtils.makeSprite(tilesTexture, 58, 5, 52, 24);
    library = SpriteUtils.makeSprite(tilesTexture, 0, 17, 16, 12);
    oldMain = SpriteUtils.makeSprite(tilesTexture, 16, 17, 6, 12);
    olin = SpriteUtils.makeSprite(tilesTexture, 42, 21, 16, 32);
    olinRiceStairs = SpriteUtils.makeSprite(tilesTexture, 38, 43, 3, 5);
    rice = SpriteUtils.makeSprite(tilesTexture, 34, 53, 24, 16);

    MapLoader.initTileMap(); // Must be called after all tiles and buildings are loaded

    //--------------------------
    //        Entities
    //--------------------------

    entitiesTexture = new Texture(getHandle("canvas/entities.png"));
    chestBrownClosed = SpriteUtils.makeSprite(tilesTexture, 0, 0);
    chestBrownOpen = SpriteUtils.makeSprite(tilesTexture, 0, 1);
    chestRedClosed = SpriteUtils.makeSprite(tilesTexture, 1, 0);
    chestRedOpen = SpriteUtils.makeSprite(tilesTexture, 1, 1);
    chestGreenClosed = SpriteUtils.makeSprite(tilesTexture, 2, 0);
    chestGreenOpen = SpriteUtils.makeSprite(tilesTexture, 2, 1);

    //--------------------------
    //       Characters
    //--------------------------

    charactersHandle = getHandle("characters");
    for (FileHandle handle : charactersHandle.list()) {
        loadCharacter(handle);
    }

    //--------------------------
    //    Handles and Caches
    //--------------------------

    itemHandle = getHandle("items.txt");
    spellHandle = getHandle("spells.txt");
    dialogueHandle = getHandle("macalester/dialogues.txt");
    cleanDialogueHandle = getHandle("macalester/dialogues_clean.txt");
    mapHandle = getHandle("macalester/maps");
    plotHandle = getHandle("macalester/plot.txt");
    entitiesHandle = getHandle("macalester/entities.txt");

    SuperParser.parseAll(AssetLoader.itemHandle, GenericItem.class);
    SuperParser.parseAll(AssetLoader.spellHandle, Spell.class);
    grids = MapLoader.generateGrids(AssetLoader.mapHandle);

    //--------------------------
    //     Music and Sounds
    //--------------------------
    //TODO: Give credit to Rolemusic for the music under the Creative Commons Attribution License
    //Artist: Rolemusic
    //Album: gigs n' contest
    worldMusic = loadMusic("Rolemusic_-_03_-_Another_beek_beep_beer_please.mp3");
    battleMusic = loadMusic("Rolemusic_-_04_-_Scape_from_the_city.mp3");
    bossMusic = loadMusic("Rolemusic_-_05_-_Death_on_the_battlefield.mp3");

    compSciMagic = Gdx.audio.newSound(getHandle("sounds/compscimagic.ogg"));
    natSciMagic = Gdx.audio.newSound(getHandle("sounds/natscimagic.ogg"));
    healingSound = Gdx.audio.newSound(getHandle("sounds/healingmagic.ogg"));
    powerupSound = Gdx.audio.newSound(getHandle("sounds/powerup.ogg"));

    BattleClass.init(); // needed to init the magic sounds

    //--------------------------
    //          Other
    //--------------------------

    font = new BitmapFont(getHandle("font/text.fnt"));
    shadow = new BitmapFont(getHandle("font/shadow.fnt"));
    scaleFont(FONT_HEIGHT / AssetLoader.font.getLineHeight());

    prefs = Gdx.app.getPreferences("com_arnopaja_supermac");
}

From source file:com.badlogic.gdx.tests.dragome.examples.bullet.BulletTestCollection.java

@Override
public void create() {
    if (app == null) {
        app = Gdx.app;//from   w  w w  .  j  a v a 2 s  .  co m
        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(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);
}

From source file:com.belocraft.mzbhelpers.AssetLoader.java

public static void load() {

    logoTexture = new Texture(Gdx.files.internal("data/logo.png"));
    logoTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new TextureRegion(logoTexture, 0, 0, 1344, 572);

    texture = new Texture(Gdx.files.internal("data/texture.png"));
    texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);

    playButtonUp = new TextureRegion(texture, 0, 83, 29, 16);
    playButtonDown = new TextureRegion(texture, 29, 83, 29, 16);
    playButtonUp.flip(false, true);//from  ww  w  . j ava  2  s.  com
    playButtonDown.flip(false, true);

    bg = new TextureRegion(texture, 0, 0, 136, 43);
    bg.flip(false, true);

    grass = new TextureRegion(texture, 0, 43, 143, 11);
    grass.flip(false, true);

    birdDown = new TextureRegion(texture, 136, 0, 17, 12);
    birdDown.flip(false, true);

    bird = new TextureRegion(texture, 153, 0, 17, 12);
    bird.flip(false, true);

    birdUp = new TextureRegion(texture, 170, 0, 17, 12);
    birdUp.flip(false, true);

    TextureRegion[] birds = { birdDown, bird, birdUp };
    birdAnimation = new Animation(0.06f, birds);
    birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);

    skullUp = new TextureRegion(texture, 192, 0, 24, 14);
    // Create by flipping existing skullUp
    skullDown = new TextureRegion(skullUp);
    skullDown.flip(false, true);

    bar = new TextureRegion(texture, 136, 16, 22, 3);
    bar.flip(false, true);

    machine = Gdx.audio.newSound(Gdx.files.internal("data/djgm.ogg"));
    dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav"));
    flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav"));
    coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav"));

    font = new BitmapFont(Gdx.files.internal("data/text.fnt"));
    font.getData().setScale(.25f, -.25f);
    shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt"));
    shadow.getData().setScale(.25f, -.25f);

    prefs = Gdx.app.getPreferences("ZombieBird");

    //   ? ?  ? ?    0
    if (!prefs.contains("highScore")) {
        prefs.putInteger("highScore", 0);
    }
}

From source file:com.gamemaker.screens.AboutScreen.java

License:Apache License

public AboutScreen(Game game) {
    this.game = game;
    cam = new OrthographicCamera();
    cam.setToOrtho(true, 1280, 720);//from ww w .  ja  v  a  2s .c  o  m
    batcher = new SpriteBatch();
    batcher.setProjectionMatrix(cam.combined);
    shapeRenderer = new ShapeRenderer();
    shapeRenderer.setProjectionMatrix(cam.combined);
    backBtn_on = AssetLoader.backBtn_on;
    backBtn_off = AssetLoader.backBtn_off;
    menuBG = AssetLoader.mapBg;
    // aboutText = AssetLoader.aboutText;
    font3 = new BitmapFont(Gdx.files.internal("font/numFont.fnt"));
    font3.getData().setScale(1f, -1f);

    backBtn = new Button(100, 100, 190, 190, backBtn_on, backBtn_off);
}

From source file:com.holotrash.lazerdeath2.lazerdeath2.java

License:Open Source License

@Override
public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, w, h);//from w w w  .j  a va2s .  c  o m
    camera.update();
    mapData = null;
    try {
        mapData = new Map(0, this);
    } catch (IOException e) {
        System.out.println("loading map data failed for level 0");
        e.printStackTrace();
    }
    gm = new GameMaster(this, mapData);
    initializeDudes();
    initializeEnemies();

    lastClickedCell = new Coord(-1, -1);
    highlightTiles = new HashMap<Coord, HighlightTile>();
    highlightOn = false;
    interactedTiles = new ArrayList<InteractedTile>();

    dudesTurnSprite = new Sprite(new Texture(Gdx.files.internal("gfx/dudes_turn.png")));
    enemiesTurnSprite = new Sprite(new Texture(Gdx.files.internal("gfx/enemy_turn.png")));
    this.leftStatusBox = new Sprite(new Texture(Gdx.files.internal("gfx/left_status_box.png")));
    this.rightStatusBox = new Sprite(new Texture(Gdx.files.internal("gfx/right_status_box.png")));
    this.rightStatusBoxFade = new Sprite(new Texture(Gdx.files.internal("gfx/right_status_box_fade_out.png")));
    this.defaultGlamourShot = new Sprite(new Texture(Gdx.files.internal("gfx/default_glamourshot.png")));
    this.glamourShot = defaultGlamourShot;
    this.endTurnButton = new Sprite(new Texture(Gdx.files.internal("gfx/end_turn.png")));
    this.attackButton = new Sprite(new Texture(Gdx.files.internal("gfx/attack_button.png")));
    this.exitGameButton = new Sprite(new Texture(Gdx.files.internal("gfx/exit_game.png")));
    this.menuButton = new Sprite(new Texture(Gdx.files.internal("gfx/menu_button.png")));
    this.unitCursor = new Sprite(new Texture(Gdx.files.internal("gfx/unit_cursor.png")));
    tiledMap = new TmxMapLoader().load("gfx/" + mapData.tmxFileName + ".tmx");
    spriteBatch = new SpriteBatch();
    highlightBatch = new SpriteBatch();
    tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap, spriteBatch);
    Gdx.input.setInputProcessor(this);
    menuDialog = new MenuDialog(this);
    dialogBox = new DialogBox();
    dialogFont = new BitmapFont(Gdx.files.internal("fonts/bank.fnt"));
    uiFont = new BitmapFont(Gdx.files.internal("fonts/hack.fnt"));
    layout = new GlyphLayout();
    this.ynDialog = new SimpleBooleanDialog("Will you eat my shit?", "Answer immediately!", "", "Jeah!",
            "Nah...");
    gm.showLevelStartDialog();
    selectedUnit = null;

    currentUnitStats = new ArrayList<String>();
    currentUnitStats.add("SELECT A UNIT TO");
    currentUnitStats.add("BEGIN PERPETUATING");
    currentUnitStats.add("THE CYCLE OF");
    currentUnitStats.add("VIOLENCE");
    currentUnitStats.add("...");

    uiConsole = new ArrayDeque<String>();
    uiConsole.push("Battle start...");

    this.screenOrigin = new Vector3(0, 768, 0);
    this.screenOrigin = camera.unproject(this.screenOrigin);

}

From source file:com.hot.ball.hotball.ui.Graphics.java

private Graphics() {
    this.shapeRenderer = new ShapeRenderer();
    this.spriteBatch = new SpriteBatch();
    this.font = new BitmapFont(Gdx.files.internal("other/font.fnt"));
    overlays = new LinkedList<>();
    yOffset = (Gdx.graphics.getHeight() - Court.COURT_HEIGHT) / 2;
}

From source file:com.hot.ball.hotball.ui.GraphicsBackUp.java

private GraphicsBackUp() {
    this.shapeRenderer = new ShapeRenderer();
    this.spriteBatch = new SpriteBatch();
    this.font = new BitmapFont(Gdx.files.internal("other/font.fnt"));
    overlays = new LinkedList<>();
}