use of com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds in project commons-gdx by gemserk.
the class SpriteBatchUtils method drawCentered.
/**
* Draws a text centered in the specified coordinates
*/
public static void drawCentered(SpriteBatch spriteBatch, BitmapFont font, CharSequence text, float x, float y) {
TextBounds bounds = font.getBounds(text);
font.draw(spriteBatch, text, x - bounds.width * 0.5f, y + bounds.height * 0.5f);
}
use of com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds in project commons-gdx by gemserk.
the class SpriteBatchUtils method drawMultilineTextWithAlignment.
public static void drawMultilineTextWithAlignment(SpriteBatch spriteBatch, BitmapFont font, CharSequence text, float x, float y, float cx, float cy, HAlignment alignment, boolean roundPosition) {
TextBounds bounds = font.getMultiLineBounds(text);
float centerx = getCenterForAlignment(cx, alignment, bounds);
if (roundPosition)
font.drawMultiLine(spriteBatch, text, Math.round(x + centerx), Math.round(y + bounds.height * cy), 0f, alignment);
else
font.drawMultiLine(spriteBatch, text, x + centerx, y + bounds.height * cy, 0f, alignment);
}
use of com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds in project commons-gdx by gemserk.
the class SpriteBatchUtils method getBounds.
public static Rectangle getBounds(BitmapFont font, CharSequence text, float x, float y, float sx, float sy) {
TextBounds bounds = font.getMultiLineBounds(text);
float w = bounds.width;
float h = bounds.height;
return new Rectangle(x - sx - w * 0.5f, y - sy - h * 0.5f, w + 2 * sx, h + 2 * sy);
}
Aggregations