@Override public void draw(Batch batch, float parentAlpha) { BitmapFontCache cache = super.getBitmapFontCache(); validate(); 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) { } }
@Override public void create () { Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchDown (int x, int y, int pointer, int newParam) { renderMode = (renderMode + 1) % 6; return false; } }); spriteBatch = new SpriteBatch(); texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); logoSprite = new Sprite(texture); logoSprite.setColor(1, 1, 1, 0.6f); logoSprite.setBounds(50, 100, 400, 100); font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle( "data/verdana39.png", FileType.Internal), false); cache = new BitmapFontCache(font); }
private void createCaches (String type, BitmapFontCache cache1, BitmapFontCache cache2, BitmapFontCache cache3, BitmapFontCache cache4, BitmapFontCache cache5) { cache1.setText("(" + type + ")", 10, 320 - 66); String text = "Sphinx of black quartz,\njudge my vow."; cache2.setColor(Color.RED); cache2.setMultiLineText(text, 5, 320 - 300); text = "How quickly\ndaft jumping zebras vex."; cache3.setColor(Color.BLUE); cache3.setMultiLineText(text, 5, 320 - 200, 470, BitmapFont.HAlignment.CENTER); text = "Kerning: LYA moo"; cache4.setText(text, 210, 320 - 66, 0, text.length() - 3); text = "Forsaking monastic tradition, twelve jovial friars gave\nup their vocation for a questionable existence on the flying trapeze."; cache5.setColor(red); cache5.setWrappedText(text, 0, 320 - 300, 480, HAlignment.CENTER); }
public Elevator(ElevatorType elevatorType, final GameGrid gameGrid) { super(elevatorType, gameGrid); if (elevatorAtlas == null) { elevatorAtlas = TowerAssetManager.textureAtlas(elevatorType.getAtlasFilename()); } floorLabelCache = new BitmapFontCache(FontManager.BankGothic32.getFont(), true); size.set(1, 3); topSprite = elevatorAtlas.createSprite("elevator/top"); topSprite.setScale(getGridScale()); bottomSprite = elevatorAtlas.createSprite("elevator/bottom"); bottomSprite.setScale(getGridScale()); shaftSprite = TowerAssetManager.sprite("elevator/shaft.png"); shaftSprite.setScale(getGridScale()); emptyShaftSprite = TowerAssetManager.sprite("elevator/empty.png"); emptyShaftSprite.setScale(getGridScale()); drawShaft = true; numCars = 1; elevatorCars = new Array<ElevatorCar>(numCars); elevatorCars.add(new ElevatorCar(this, elevatorAtlas)); tmpVector = new Vector2(); }
public GameScreen(final Game game) { super(game); font = new BitmapFontCache(new BitmapFont()); // Gameplay buttons buttonMoveRight = new Button("data/button.png", "data/button.png", 200f, 20f); buttonMoveLeft = new Button("data/button.png", "data/button.png", 50f, 20f); buttonJump = new Button("data/button.png", "data/button.png", 600f, 20f); buttonPause = new Button("data/pause.png", "data/pause.png", 0f, 445f, true); // Pausescreen buttons buttonResume = new Button("data/play.png", "data/play.png", 0f, 445f, false); buttonExit = new Button("data/exit.png", "data/exit.png", 350f, 220f); map = new Map(); theodor = new Theodor(150, 200, 80, 400, new Rectangle(), new Rectangle(), "data/character/tests/kreis.png", batch); //TODO add walkSheetName Gdx.input.setInputProcessor(new Input(this, theodor, buttonMoveRight, buttonMoveLeft, buttonJump, buttonPause, buttonResume)); }
public KotcrabText(BitmapFont bitmapFont, String text, boolean alwaysSetOriginToMiddle, float x, float y) { bitmapFontCache = new BitmapFontCache(bitmapFont); //przygotowanie tekstu textBounds = bitmapFontCache.setText(text, 0, 0); position = new Vector2(x, y); //ustawienie pozycji scale = new Vector2(1, 1); //ustaiwnie skali rotation = 0; //ustawienie rotacji autoSetOriginToMiddle = alwaysSetOriginToMiddle; //config automatycznego origina if (autoSetOriginToMiddle == true) { calculateOrigin(); //obliczenie wlasciwego origina } else origin = new Vector2(0, 0); //ustawienie orgina na 0 color = new FontColor(); //kolor newMatrix = new Matrix4(); //matrix translate(); }
@Override public void update(BitmapFontCache cache, String text, float renderWidth, int hAlign, float delta) { if(characterIndex >= text.length() - 1) { if(!isFinished()) { cache.clear(); cache.addText(text.substring(0, characterIndex), 0f, 0f, renderWidth, hAlign, true); setFinished(true); } return; } timer += delta; if(timer >= speed) { timer -= speed; characterIndex++; cache.clear(); cache.addText(text.substring(0, characterIndex), 0f, 0f, renderWidth, hAlign, true); } }
public void draw(SpriteBatch paramSpriteBatch, float paramFloat) { validate(); Color localColor1 = getColor(); if (this.style.background != null) { paramSpriteBatch.setColor(localColor1.r, localColor1.g, localColor1.b, paramFloat * localColor1.a); this.style.background.draw(paramSpriteBatch, getX(), getY(), getWidth(), getHeight()); } BitmapFontCache localBitmapFontCache = this.cache; if (this.style.fontColor == null); for (Color localColor2 = localColor1; ; localColor2 = Color.tmp.set(localColor1).mul(this.style.fontColor)) { localBitmapFontCache.setColor(localColor2); this.cache.setPosition(getX(), getY()); this.cache.draw(paramSpriteBatch, paramFloat * localColor1.a); return; } }
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); }
@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); }
@Override public void render(final GraphicsService graphicsService) { final BitmapFontCache fontCache = new BitmapFontCache(parent.getFont()); fontCache.addText( newText, graphicsService.getCameraOffsetX() + parent.getContentPositionX(), graphicsService.getCameraOffsetY() + parent.getContentPositionY() + parent.getHeight() ); fontCache.draw(graphicsService.getSpriteBatch(), 0, glyphCountTween.getValue()); }
public static GlyphLayout Measure(BitmapFont font,String txt) { if (txt == null || txt.equals("")) txt = "text"; BitmapFontCache measureNormalCache = new BitmapFontCache(font); GlyphLayout bounds = measureNormalCache.setText(txt, 0, 0); bounds.height = bounds.height - measureNormalCache.getFont().getDescent(); return bounds; }
public static GlyphLayout MeasureWrapped(BitmapFont font, String txt, float width) { if (txt == null || txt.equals("")) txt = "text"; BitmapFontCache measureNormalCache = new BitmapFontCache(font); GlyphLayout bounds = measureNormalCache.setText(txt, 0, 0, width, 0, true); bounds.height = bounds.height - measureNormalCache.getFont().getDescent(); return bounds; }
public SquadCommandCard(final Entity squad, int index, Skin skin){ super(index, skin); this.squad = squad; squadText = new BitmapFontCache(skin.getFont("default-font")); setSquad(squad); }
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(); }
public void setStyle (LabelStyle style) { if (style == null) throw new IllegalArgumentException("style cannot be null."); if (style.font == null) throw new IllegalArgumentException("Missing LabelStyle font."); this.style = style; cache = new BitmapFontCache(style.font, style.font.usesIntegerPositions()); invalidateHierarchy(); }
@Override public void create () { Preferences pref = Gdx.app.getPreferences("test"); boolean resultb = pref.getBoolean("test"); int resulti = pref.getInteger("test"); shader = new ShaderProgram(Gdx.files.internal("data/shaders/shader-vs.glsl"), Gdx.files.internal("data/shaders/shader-fs.glsl")); if (!shader.isCompiled()) throw new GdxRuntimeException(shader.getLog()); mesh = new Mesh(VertexDataType.VertexBufferObject, true, 6, 0, VertexAttribute.Position(), VertexAttribute.TexCoords(0)); mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 0, 1, 0.5f, -0.5f, 0, 1, 1, 0.5f, 0.5f, 0, 1, 0, 0.5f, 0.5f, 0, 1, 0, -0.5f, 0.5f, 0, 0, 0, -0.5f, -0.5f, 0, 0, 1}); texture = new Texture(new Pixmap(Gdx.files.internal("data/badlogic.jpg")), true); texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); String params = Gdx.files.internal("data/gwttestparams.txt").readString(); numSprites = Integer.parseInt(params); batch = new SpriteBatch(); positions = new ArrayList<Vector2>(); for (int i = 0; i < numSprites; i++) { positions.add(new Vector2(MathUtils.random() * Gdx.graphics.getWidth(), MathUtils.random() * Gdx.graphics.getHeight())); } sprite = new Sprite(texture); sprite.setSize(64, 64); sprite.setOrigin(32, 32); font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false); cache = new BitmapFontCache(font); cache.setColor(Color.RED); cache.setMultiLineText("This is a Test", 0, 0); atlas = new TextureAtlas(Gdx.files.internal("data/pack")); }
@Override public void create () { Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchDown (int x, int y, int pointer, int newParam) { renderMode = (renderMode + 1) % 4; return false; } }); spriteBatch = new SpriteBatch(); spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1)); texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); logoSprite = new Sprite(texture); logoSprite.flip(false, true); logoSprite.setPosition(0, 320 - 256); logoSprite.setColor(1, 1, 1, 0.5f); font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true); cache1 = new BitmapFontCache(font); cache2 = new BitmapFontCache(font); cache3 = new BitmapFontCache(font); cache4 = new BitmapFontCache(font); cache5 = new BitmapFontCache(font); createCaches("cached", cache1, cache2, cache3, cache4, cache5); font.setScale(1.33f); cacheScaled1 = new BitmapFontCache(font); cacheScaled2 = new BitmapFontCache(font); cacheScaled3 = new BitmapFontCache(font); cacheScaled4 = new BitmapFontCache(font); cacheScaled5 = new BitmapFontCache(font); createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5); }
public void create () { TextureAtlas textureAtlas = new TextureAtlas("data/pack"); font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), textureAtlas.findRegion("verdana39"), false); singleLineCache = new BitmapFontCache(font, true); multiLineCache = new BitmapFontCache(font, true); singleLineCacheNonInteger = new BitmapFontCache(font, false); multiLineCacheNonInteger = new BitmapFontCache(font, false); batch = new SpriteBatch(); fillCaches(); }
public void init (BitmapFont bitmapFont, String text) { this.text = text; cache = new BitmapFontCache(bitmapFont); translationMatrix = new Matrix4(); textLayout = new GlyphLayout(); setText(text); }
public Card(Type type, int x, int y, String text, String name) { this.type = type; face = Face.back; setX(x); setY(y); font = new BitmapFont(Gdx.files.internal("data/font.fnt"), false); staticText = new BitmapFontCache(font); cardText = text; initScaleX = getScaleX(); this.name = name; effectList = new ArrayList<Effect>(); activated = false; }
@Override public void update(BitmapFontCache cache, String text, float renderWidth, int hAlign, float delta) { if(!isFinished()) { cache.addText(text, 0f, 0f, renderWidth, hAlign, true); } setFinished(true); }
public TextSprite(int x, int y, String s, Color color) { super(0, 0); this.cache = new BitmapFontCache(font); cache.setColor(color); setText(s); this.x = x; this.y = y; }
public void setStyle(Window.WindowStyle paramWindowStyle) { if (paramWindowStyle == null) throw new IllegalArgumentException("style cannot be null."); this.style = paramWindowStyle; setBackground(paramWindowStyle.background); this.titleCache = new BitmapFontCache(paramWindowStyle.titleFont); this.titleCache.setColor(paramWindowStyle.titleFontColor); invalidateHierarchy(); }
public void setStyle(Label.LabelStyle paramLabelStyle) { if (paramLabelStyle == null) throw new IllegalArgumentException("style cannot be null."); if (paramLabelStyle.font == null) throw new IllegalArgumentException("Missing LabelStyle font."); this.style = paramLabelStyle; if ((this.cache == null) || (paramLabelStyle.font != this.cache.getFont())) { this.cache = new BitmapFontCache(paramLabelStyle.font, paramLabelStyle.font.usesIntegerPositions()); computeBounds(); invalidateHierarchy(); } }
public final f a(p paramp) { an.a(o.d()); aj.a("LoadMainUiSkin"); o.a(new Skin(c.a("{data:common/data/nemesis.json,data-xhdpi:common/data-xhdpi/nemesis.json,data-xxhdpi:common/data-xxhdpi/nemesis.json}"), o.d(), r.a())); BitmapFontCache.enableMulticolor(d.a()); an.a(o.e()); aj.b(); return null; }
public final void draw(SpriteBatch paramSpriteBatch, float paramFloat) { float f1 = paramFloat * getColor().a; Color localColor1; BitmapFontCache localBitmapFontCache; int m; if (f1 > 0.0F) { localColor1 = getColor(); if (this.b.background != null) { paramSpriteBatch.setColor(localColor1.r, localColor1.g, localColor1.b, paramFloat * localColor1.a); this.b.background.draw(paramSpriteBatch, getX(), getY(), getWidth(), getHeight()); } localBitmapFontCache = getFontCache(); localBitmapFontCache.setPosition(getX() + this.k, getY() + this.l); m = Math.min(this.d, localBitmapFontCache.getGlyphCount()); int n = 20 * Math.max(0, m - this.b.maxCharacters); a.a(paramSpriteBatch); a.b(20 * localBitmapFontCache.getGlyphCount()); a.a(n); if (this.b.fontColor != null) break label218; } label218: for (Color localColor2 = localColor1; ; localColor2 = Color.tmp.set(localColor1).mul(this.b.fontColor)) { localBitmapFontCache.setColor(localColor2); localBitmapFontCache.draw(a, f1, m); a.a(null); return; } }
@Override public BitmapFontCache getBitmapFontCache () { return super.getBitmapFontCache(); }
/** * @see com.badlogic.gdx.graphics.g2d.BitmapFont#getCache() */ @Override public BitmapFontCache getCache() { return wrapped.getCache(); }
/** * @see com.badlogic.gdx.graphics.g2d.BitmapFont#newFontCache() */ @Override public BitmapFontCache newFontCache() { if (wrapped == null) return super.newFontCache(); return wrapped.newFontCache(); }
/** Allows subclasses to access the cache in {@link #draw(Batch, float)}. */ protected BitmapFontCache getBitmapFontCache () { return cache; }
@Override public void render () { // red.a = (red.a + Gdx.graphics.getDeltaTime() * 0.1f) % 1; int viewHeight = Gdx.graphics.getHeight(); Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); spriteBatch.begin(); String text = "Sphinx of black quartz, judge my vow."; font.setColor(Color.RED); float x = 100, y = 20; float alignmentWidth; if (false) { alignmentWidth = 0; font.drawMultiLine(spriteBatch, text, x, viewHeight - y, alignmentWidth, HAlignment.RIGHT); } if (false) { TextBounds bounds = font.getMultiLineBounds(text); alignmentWidth = bounds.width; font.drawMultiLine(spriteBatch, text, x, viewHeight - y, alignmentWidth, HAlignment.RIGHT); } if (true) { alignmentWidth = 280; // font.drawMultiLine(spriteBatch, text, x, viewHeight - y, alignmentWidth, HAlignment.RIGHT); font.drawWrapped(spriteBatch, text, x, viewHeight - y, alignmentWidth, HAlignment.RIGHT); } // 'R' and 'p' are in different pages String txt2 = "this font uses " + multiPageFont.getRegions().length + " texture pages: RpRpRpRpRpNM"; spriteBatch.renderCalls = 0; // regular draw function multiPageFont.setColor(Color.BLUE); multiPageFont.draw(spriteBatch, txt2, 10, 100); // expert usage.. drawing with bitmap font cache BitmapFontCache cache = multiPageFont.getCache(); cache.clear(); cache.setColor(Color.BLACK); cache.setText(txt2, 10, 50); cache.setColors(Color.PINK, 3, 6); cache.setColors(Color.ORANGE, 9, 12); cache.setColors(Color.GREEN, 16, txt2.length()); cache.draw(spriteBatch, 5, txt2.length() - 5); cache.clear(); cache.setColor(Color.BLACK); float textX = 10; textX += cache.setText("[black] ", textX, 150).width; multiPageFont.setMarkupEnabled(true); textX += cache.addText("[[[PINK]pink[]] ", textX, 150).width; textX += cache.addText("[PERU][[peru] ", textX, 150).width; cache.setColor(Color.GREEN); textX += cache.addText("green ", textX, 150).width; textX += cache.addText("[#A52A2A]br[#A52A2ADF]ow[#A52A2ABF]n f[#A52A2A9F]ad[#A52A2A7F]in[#A52A2A5F]g o[#A52A2A3F]ut ", textX, 150).width; multiPageFont.setMarkupEnabled(false); cache.draw(spriteBatch); spriteBatch.end(); // System.out.println(spriteBatch.renderCalls); renderer.begin(ShapeType.Line); renderer.setColor(Color.BLACK); renderer.rect(x, viewHeight - y, x + alignmentWidth, 300); renderer.end(); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); }
public void setFont (BitmapFont font) { cache = new BitmapFontCache(font); setText(text); }
public BitmapFontCache getCache () { return cache; }
public BitmapFontCache getBitmapFontCache() { return bitmapFontCache; }
@Override public void interpolate(BitmapFontCache cache, String text, float alpha) {}
@Override public void render(BitmapFontCache cache, Graphics g, int renderX, int renderY) { cache.setPosition(renderX, renderY); g.drawBitmapFontCache(cache); }