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

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

Introduction

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

Prototype

public TextBounds getWrappedBounds(CharSequence str, float wrapWidth) 

Source Link

Document

Returns the bounds of the specified text, which may contain newlines and is wrapped within the specified width.

Usage

From source file:org.bladecoder.bladeengine.util.TextUtils.java

License:Apache License

public static float getCenterX(BitmapFont font, CharSequence str, float maxLength, int viewportWidth) {
    float x;/*from  w ww  .  j av a2s  .c o  m*/

    TextBounds b = font.getWrappedBounds(str, maxLength);

    x = (viewportWidth - b.width) / 2;

    return x;
}

From source file:org.bladecoder.bladeengine.util.TextUtils.java

License:Apache License

public static float getCenterY(BitmapFont font, CharSequence str, float maxLength, int viewportHeight) {
    float y;//from  w  ww  .j a  v a2  s . c o m

    TextBounds b = font.getWrappedBounds(str, maxLength);

    y = (viewportHeight + b.height) / 2;

    return y;
}