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

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

Introduction

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

Prototype

public void scale(float amount) 

Source Link

Document

Sets the font's scale relative to the current scale.

Usage

From source file:com.blackboxgaming.engine.factories.LayerFactory.java

public static Layer createScoreLayer() {
    Stage stage = new Stage();
    Table table = new Table();
    BitmapFont font = new BitmapFont();
    font.scale(2);
    Button button;/*from w w  w.ja  v  a2  s . com*/

    Skin skin = new Skin();
    skin.add("bluebox", new Texture("textures/bluebox.jpg"));
    skin.add("greenbox", new Texture("textures/greenbox.jpg"));
    skin.add("redbox", new Texture("textures/redbox2.jpg"));

    ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("redbox"),
            skin.getDrawable("greenbox"), skin.getDrawable("bluebox"), font);

    button = new ImageTextButton("0", style);
    button.setHeight(150);
    button.setWidth(150);
    button.setName(((ImageTextButton) button).getText().toString());
    table.add(button).pad(5).center();

    table.pack();
    table.setPosition(Gdx.graphics.getWidth() / 2 - table.getWidth() / 2,
            Gdx.graphics.getHeight() - table.getHeight());
    stage.addActor(table);

    Global.scoreButton = button;
    return new Layer("scoreLayer", stage);
}

From source file:com.sadafnoor.accelerometerInputProcessorTests.AccelerometerInputProcessorTestScreen.java

License:Apache License

public void create() {
    batch = new SpriteBatch();
    stage = new Stage();
    //      Gdx.input.setInputProcessor(stage);
    Gdx.input.setInputProcessor(this);

    // A skin can be loaded via JSON or defined programmatically, either is fine. Using a skin is optional but strongly
    // recommended solely for the convenience of getting a texture, region, etc as a drawable, tinted drawable, etc.
    skin = new Skin();

    //skin.add("white", new Texture(pixmap));

    // Store the default libgdx font under the name "default".
    BitmapFont bfont = new BitmapFont();
    bfont.scale(1);
    skin.add("default", bfont);

    textButtonStyle = new TextButtonStyle();
    textButtonStyle.font = skin.getFont("default");
    skin.add("default", textButtonStyle);

    // Create a button with the "default" TextButtonStyle. A 3rd parameter can be used to specify a name other than "default".
    textButton = new TextButton("initial", skin);
    textButton.setPosition(50, 50);/*from www .ja v a2s . c om*/
    stage.addActor(textButton);

}

From source file:org.deathsbreedgames.gnp2.renderers.ClassicModeRenderer.java

public ClassicModeRenderer(ClassicModeScreen screen) {
    this.screen = screen;

    // Setup buttons:
    buttonStage = new Stage();
    TextureAtlas buttonAtlas = new TextureAtlas("gfx/buttons.pack");
    Skin buttonSkin = new Skin(buttonAtlas);

    Gdx.input.setInputProcessor(buttonStage);

    BitmapFont buttonFont = new BitmapFont();
    buttonFont.scale(0.1f);

    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = buttonSkin.getDrawable("button_green");
    buttonStyle.checked = buttonSkin.getDrawable("button_red");
    buttonStyle.font = buttonFont;//from ww w  . ja  v  a 2  s  . c om

    // Inverse is needed for if game starts and sound/music is off
    TextButtonStyle buttonStyleInverse = new TextButtonStyle();
    buttonStyleInverse.up = buttonSkin.getDrawable("button_red");
    buttonStyleInverse.checked = buttonSkin.getDrawable("button_green");
    buttonStyleInverse.font = buttonFont;

    TextButton soundButton = new TextButton("S", buttonStyle);
    if (!GlobalVars.soundOn) {
        soundButton.setStyle(buttonStyleInverse);
    }
    soundButton.pad(0, 10, 0, 10);
    soundButton.setPosition(Gdx.graphics.getWidth() - soundButton.getWidth(),
            Gdx.graphics.getHeight() - soundButton.getHeight());
    buttonStage.addActor(soundButton);
    soundButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            // Turn sound on/off accordingly
            if (getSoundOn()) {
                setSoundOff();
            } else {
                setSoundOn();
            }
        }
    });

    TextButton musicButton = new TextButton("M", buttonStyle);
    if (!GlobalVars.musicOn) {
        musicButton.setStyle(buttonStyleInverse);
    }
    musicButton.setPosition(soundButton.getX() - musicButton.getWidth(),
            Gdx.graphics.getHeight() - musicButton.getHeight());
    buttonStage.addActor(musicButton);
    musicButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            // Turn music on/off accordingly
            if (getMusicOn()) {
                setMusicOff();
            } else {
                setMusicOn();
            }
        }
    });

    // Setup drawing fonts
    scoreFont = new BitmapFont();
    pausedFont = new BitmapFont();
    pausedFont.scale(1.5f);

    // Setup graphics
    batch = new SpriteBatch();
    bg = new Texture(Gdx.files.internal("gfx/bg.jpg"));
    TextureAtlas spriteAtlas = new TextureAtlas("gfx/sprites.pack");
    pBlue = spriteAtlas.createSprite("Paddle_blue");
    pRed = spriteAtlas.createSprite("Paddle_red");
    ball = spriteAtlas.createSprite("Ball_orange");
}

From source file:org.deathsbreedgames.gnp2.renderers.GroupModeRenderer.java

public GroupModeRenderer(GroupModeScreen screen) {
    this.screen = screen;

    // Setup buttons
    buttonStage = new Stage();
    TextureAtlas buttonAtlas = new TextureAtlas("gfx/buttons.pack");
    Skin buttonSkin = new Skin(buttonAtlas);

    Gdx.input.setInputProcessor(buttonStage);

    BitmapFont buttonFont = new BitmapFont();
    buttonFont.scale(0.1f);

    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = buttonSkin.getDrawable("button_green");
    buttonStyle.checked = buttonSkin.getDrawable("button_red");
    buttonStyle.font = buttonFont;//from ww w . j a v  a 2 s .c om

    // Inverse is needed for if game starts and sound/music is off
    TextButtonStyle buttonStyleInverse = new TextButtonStyle();
    buttonStyleInverse.up = buttonSkin.getDrawable("button_red");
    buttonStyleInverse.checked = buttonSkin.getDrawable("button_green");
    buttonStyleInverse.font = buttonFont;

    TextButton soundButton = new TextButton("S", buttonStyle);
    if (!GlobalVars.soundOn) {
        soundButton.setStyle(buttonStyleInverse);
    }
    soundButton.pad(0, 10, 0, 10);
    soundButton.setPosition(Gdx.graphics.getWidth() - soundButton.getWidth(),
            Gdx.graphics.getHeight() - soundButton.getHeight());
    buttonStage.addActor(soundButton);
    soundButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            // Turn sound on/off accordingly
            if (getSoundOn()) {
                setSoundOff();
            } else {
                setSoundOn();
            }
        }
    });

    TextButton musicButton = new TextButton("M", buttonStyle);
    if (!GlobalVars.musicOn) {
        musicButton.setStyle(buttonStyleInverse);
    }
    musicButton.setPosition(soundButton.getX() - musicButton.getWidth(),
            Gdx.graphics.getHeight() - musicButton.getHeight());
    buttonStage.addActor(musicButton);
    musicButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            // Turn music on/off accordingly
            if (getMusicOn()) {
                setMusicOff();
            } else {
                setMusicOn();
            }
        }
    });

    // Setup drawing fonts
    scoreFont = new BitmapFont();
    pausedFont = new BitmapFont();
    pausedFont.scale(1.5f);

    // Setup graphics
    batch = new SpriteBatch();
    bg = new Texture(Gdx.files.internal("gfx/bg.jpg"));
    TextureAtlas spriteAtlas = new TextureAtlas("gfx/sprites.pack");
    pBlue = spriteAtlas.createSprite("Paddle_blue");
    pRed = spriteAtlas.createSprite("Paddle_red");
    pGreen = spriteAtlas.createSprite("Paddle_green");
    pPurple = spriteAtlas.createSprite("Paddle_purple");
    ball = spriteAtlas.createSprite("Ball_orange");
}