com.badlogic.gdx.graphics.g2d.BitmapFontCache Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g2d.BitmapFontCache. 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: TypingLabel.java    From typing-label with MIT License 6 votes vote down vote up
@Override
public void draw(Batch batch, float parentAlpha) {
    super.validate();
    addMissingGlyphs();

    // Update cache with new glyphs
    BitmapFontCache bitmapFontCache = getBitmapFontCache();
    getBitmapFontCache().setText(getGlyphLayout(), lastLayoutX, lastLayoutY);

    // Tint glyphs
    for(TypingGlyph glyph : glyphCache) {
        if(glyph.internalIndex >= 0 && glyph.color != null) {
            bitmapFontCache.setColors(glyph.color, glyph.internalIndex, glyph.internalIndex + 1);
        }
    }

    super.draw(batch, parentAlpha);
}
 
Example #2
Source File: Label.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public void draw(PaletteIndexedBatch batch, float a) {
  validate();

  LabelStyle style = getStyle();
  if (style != null) {
    Drawable background = style.background;
    if (background != null) {
      background.draw(batch,
          getX() - background.getLeftWidth(), getY() - background.getBottomHeight(),
          getWidth() + background.getMinWidth(), getHeight() + background.getMinHeight());
    }
  }

  batch.setBlendMode(((FontTBL.BitmapFont) getStyle().font).getBlendMode());
  BitmapFontCache cache = getBitmapFontCache();
  cache.setPosition(getX(), getY());
  cache.tint(getColor());
  cache.draw(batch);
  batch.resetBlendMode();
}
 
Example #3
Source File: Window.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public void setStyle (WindowStyle style) {
	if (style == null) throw new IllegalArgumentException("style cannot be null.");
	this.style = style;
	setBackground(style.background);
	titleCache = new BitmapFontCache(style.titleFont);
	titleCache.setColor(style.titleFontColor);
	if (title != null) setTitle(title);
	invalidateHierarchy();
}
 
Example #4
Source File: SlotActor.java    From Cubes with MIT License 5 votes vote down vote up
public static void drawText(Batch batch, float x, float y, ItemStack itemStack) {
  if (itemStack == null || itemStack.item.getStackCountMax() == 1) return;
  BitmapFontCache cache = Fonts.smallHUD.getCache();
  cache.clear();
  GlyphLayout layout = cache.addText(Integer.toString(itemStack.count), x, y, 32f, Align.right, false);
  cache.translate(0, layout.height);
  cache.draw(batch);
}
 
Example #5
Source File: IntegerSetting.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public void draw(Batch batch, float parentAlpha) {
  super.draw(batch, parentAlpha);
  BitmapFontCache cache = Fonts.hud.getCache();
  cache.clear();
  GlyphLayout layout = cache.addText(String.format(format, getValue()), getX(), getY(), getWidth(), Align.center, false);
  cache.translate(0, (layout.height / 2) + (getHeight() / 2));
  cache.draw(batch);
}
 
Example #6
Source File: TypingLabel.java    From typing-label with MIT License 4 votes vote down vote up
@Override
public BitmapFontCache getBitmapFontCache() {
    return super.getBitmapFontCache();
}