com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Window.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
protected void drawBackground (Batch batch, float parentAlpha, float x, float y) {
	float width = getWidth(), height = getHeight();
	float padTop = getPadTop();

	super.drawBackground(batch, parentAlpha, x, y);

	// Draw button table.
	buttonTable.getColor().a = getColor().a;
	buttonTable.pack();
	buttonTable.setPosition(width - buttonTable.getWidth(), Math.min(height - padTop, height - buttonTable.getHeight()));
	buttonTable.draw(batch, parentAlpha);

	// Draw the title without the batch transformed or clipping applied.
	y += height;
	TextBounds bounds = titleCache.getBounds();
	if ((titleAlignment & Align.left) != 0)
		x += getPadLeft();
	else if ((titleAlignment & Align.right) != 0)
		x += width - bounds.width - getPadRight();
	else
		x += (width - bounds.width) / 2;
	if ((titleAlignment & Align.top) == 0) {
		if ((titleAlignment & Align.bottom) != 0)
			y -= padTop - bounds.height;
		else
			y -= (padTop - bounds.height) / 2;
	}
	titleCache.setColors(tmpColor.set(getColor()).mul(style.titleFontColor));
	titleCache.setPosition((int)x, (int)y - 15); // HACK for Kenney's skin only!!
	titleCache.draw(batch, parentAlpha);
}
 
Example #2
Source File: MyButton.java    From killingspree with MIT License 5 votes vote down vote up
public boolean isPressed(Vector2 touchVector, BitmapFont font) {
    TextBounds bounds = font.getBounds(text);
    if(touchVector.x > x && touchVector.x < x + bounds.width &&
            touchVector.y < y && touchVector.y > y - bounds.height) {
        return true;
    }
    return false;
}
 
Example #3
Source File: Message.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public Message () {
	bounds = new TextBounds();
}