List of usage examples for com.badlogic.gdx.graphics.g2d BitmapFontCache setPosition
public void setPosition(float x, float y)
From source file:com.ridiculousRPG.ui.DisplayPlainTextService.java
License:Apache License
/** * Adds a message which will be drawn onto the screen (To increase the * performance you should not compute the colors floatbits at every * iteration)/* ww w.j a va 2s.c o m*/ * * @param wrapWidth * If wrapWidth > 0 then the text will be wrapped at the * specified bound. * @param forceRemove * to remove the message immediately after displaying it * (displays it for only one frame). * @see {@link Color#toFloatBits()} */ public BitmapFontCache addMessage(CharSequence text, float color, Alignment horizontalAlign, Alignment verticalAlign, float padding, float wrapWidth, boolean forceRemove) { Rectangle bounds = GameBase.$().getScreen(); Camera cam = GameBase.$().getCamera(); if (projectionMatrix(cam) == cam.projection) { bounds = GameBase.$().getPlane(); } float x = padding, y = bounds.height - padding; BitmapFontCache bfc = createMsg(text, color, 0f, 0f, wrapWidth); TextBounds b = bfc.getBounds(); if (horizontalAlign == Alignment.CENTER) x = (bounds.width - b.width) * .5f; else if (horizontalAlign == Alignment.RIGHT) x = bounds.width - b.width - padding; if (verticalAlign == Alignment.CENTER) y = bounds.height - (bounds.height - b.height) * .5f; else if (verticalAlign == Alignment.BOTTOM) y = b.height + padding; if (projectionMatrix(cam) == cam.view) { if (x < 0f) x = 0f; if (y > bounds.height) y = bounds.height; } int ix = (int) (x + .5f); int iy = (int) (y + .5f); bfc.setPosition(ix, iy); if (forceRemove) msgDisplayOnce.add(bfc); else msgDisplay.add(bfc); return bfc; }
From source file:de.longri.cachebox3.gui.widgets.ScrollLabel.java
License:Open Source License
@Override public void draw(Batch batch, float parentAlpha) { BitmapFontCache cache = super.getBitmapFontCache(); validate();// ww w . ja v a 2s . c om Color color = tempColor.set(getColor()); color.a *= parentAlpha; if (style.background != null) { batch.setColor(color.r, color.g, color.b, color.a); style.background.draw(batch, getX(), getY(), getWidth(), getHeight()); } if (style.fontColor != null) color.mul(style.fontColor); cache.tint(color); cache.setPosition(getX() + scrollPosition, getY()); getStage().calculateScissors(localRec, scissorRec); ScissorStack.pushScissors(scissorRec); cache.draw(batch); batch.flush(); try { ScissorStack.popScissors(); } catch (Exception e) { } }