public static void draw(Batch batch, float posX, float posY, float width, float height, Color color) { if (texture == null) texture = makePixel(); float tmp = batch.getPackedColor(); batch.setColor(color); batch.draw(texture, posX, posY, 0, 0, width, height, 1, 1, 0, 0, 0, 1, 1, false, false); batch.setPackedColor(tmp); }
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); if (renderer == null || ((AnimationRenderer) renderer).getCurrentAnimation() == null) return; float tmp = batch.getPackedColor(); batch.setColor(Color.WHITE); renderer.update(Gdx.graphics.getDeltaTime()); RectangleRenderer.draw(batch, getX(), getY(), getWidth(), getHeight(), Color.MAGENTA); float scalew = getWidth() / renderer.getWidth(); float scaleh = getHeight() / renderer.getHeight(); float scale = scalew > scaleh ? scaleh : scalew; renderer.draw((SpriteBatch) batch, getX() + renderer.getWidth() * scale / 2, getY(), scale, scale, 0f, null); batch.setPackedColor(tmp); }
defaultFont.draw(batch, textLayout, 5, getHeight() + getY() - 10); batch.setPackedColor(tmp);