@Override public void render () { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.setProjectionMatrix(camera.combined); batch.begin(); float x = 10; float y = Gdx.graphics.getHeight() - 10; int renderCalls = 0; // NOTE: Before production release on mobile, you should cache the array from values() // inside the Enum in order to reduce allocations in the render loop. for (FontStyle style : FontStyle.values()) { for (FontSize size : FontSize.values()) { BitmapFont fnt = getFont(style, size); fnt.draw(batch, style.name() + " " + size.size + "pt: The quick brown fox jumps over the lazy dog", x, y); y -= fnt.getLineHeight() + 10; } y -= 20; } BitmapFont font = getFont(FontStyle.Regular, FontSize.Medium); font.draw(batch, text, 10, font.getCapHeight() + 10); // draw all glyphs in background batch.setColor(1f, 1f, 1f, 0.15f); batch.draw(regions.first(), 0, 0); batch.setColor(1f, 1f, 1f, 1f); batch.end(); }
@Override public void render() { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.setProjectionMatrix(camera.combined); batch.begin(); float x = 10; float y = Gdx.graphics.getHeight() - 10; int renderCalls = 0; // NOTE: Before production release on mobile, you should cache the array from values() // inside the Enum in order to reduce allocations in the render loop. for (FontStyle style : FontStyle.values()) { for (FontSize size : FontSize.values()) { BitmapFont fnt = getFont(style, size); fnt.draw(batch, style.name() + " " + size.size + "pt: The quick brown fox jumps over the lazy dog", x, y); y -= fnt.getLineHeight() + 10; } y -= 20; } BitmapFont font = getFont(FontStyle.Regular, FontSize.Medium); font.draw(batch, text, 10, font.getCapHeight() + 10); // draw all glyphs in background batch.setColor(1f, 1f, 1f, 0.15f); batch.draw(packer.getPages().first().getTexture(), 0, 0); batch.setColor(1f, 1f, 1f, 1f); batch.end(); }
spriteBatch.setColor(col); for (int i = 0; i < coords2.length; i += 2) spriteBatch.draw(texture2, coords2[i], coords2[i + 1], 0, 0, 32, 32);
b.setColor(1, 1, 1, Interpolation.sine.apply(timePassed / 2f));
public void resetAlpha() { alphaEnabled = false; alpha = 0xff; currentColor.a = this.alpha / (float) Layer.MAX_OPACITY; batch.setColor(1, 1, 1, currentColor.a); }
public void draw(SpriteBatch batch, float parentAlpha) { final Color c = getColor(); batch.setColor(c.r, c.g, c.b, c.a * parentAlpha); batch.draw(sprite, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); }
public void draw(SpriteBatch batch, float parentAlpha) { //!!!!!!!!!!!!!!!Error in this place. Draw() not called from stage batch.setColor(getColor()); batch.draw(Assets.btnPlayRegion, 0, 0); }
@Override public void setColor(float color) { super.setColor(filter.alter(color)); } }
@Override public void draw(SpriteBatch batch, float _) { batch.setColor(1,1,1,1); super.draw(batch, _); batch.draw(current[disabled ? 0 : state], getX(), getY(), getWidth(), getHeight()); }
@Override public void draw (SpriteBatch batch, float parentAlpha) { batch.setColor(1, 1, 1, parentAlpha); batch.draw(texture, x, y); }
@Override public void setTint(Color tint) { if (rendering) { endRendering(); } this.tint = tint; spriteBatch.setColor(tint); }
@Override public void setColor(float r, float g, float b, float a) { int intBits = ((int)(255 * a) & 0xFE) << 24 | (int)(255 * b) << 16 | (int)(255 * g) << 8 | (int)(255 * r); super.setColor(filter.alter(NumberTools.intBitsToFloat(intBits))); }
public void setOpacity(int opacity) { endBatch(); if (!alphaEnabled) { alphaEnabled = true; } beginBatch(); this.alpha = opacity; currentColor.a = this.alpha / (float) Layer.MAX_OPACITY; batch.setColor(1, 1, 1, currentColor.a); }
@Override protected void begin() { batch.setProjectionMatrix(cameraSystem.camera.combined); batch.begin(); batch.setColor(1f, 1f, 1f, 1f); }
public class RaindDrop extends Actor { TextureRegion region; public RaindDrop () { region = new TextureRegion(...); } public void draw (SpriteBatch batch, float parentAlpha) { Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); batch.draw(...); } }
@Override protected void begin() { batch.setProjectionMatrix(cameraSystem.camera.combined); batch.begin(); batch.setColor(1f, 1f, 1f, 1f); }
private void batchColorEnd (SpriteBatch batch) { batch.end(); batch.flush(); batch.setColor(1, 1, 1, 1); batch.begin(); }
private void batchColorStart (SpriteBatch batch, float r, float g, float b) { batch.end(); batch.flush(); batch.setColor(r, g, b, 1); batch.begin(); }