com.badlogic.gdx.graphics.g2d.Batch Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.g2d.Batch.
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: PolylineRenderer.java From talos with Apache License 2.0 | 6 votes |
@Override public void draw(Batch batch, float x, float y, float width, float height, float rotation) { Polyline polyline = polyline(); polyline.set(width, rotation); polyline.draw(batch, region, x, y); tmpArr.clear(); for(Particle key: polylineMap.keys()) { if(key.alpha == 1f) { tmpArr.add(key); } } for(int i = 0; i < tmpArr.size; i++) { if(polylineMap.containsKey(tmpArr.get(i))) { polylinePool.free(polylineMap.get(tmpArr.get(i))); } polylineMap.remove(tmpArr.get(i)); } }
Example #2
Source File: ChatActor.java From Cubes with MIT License | 6 votes |
@Override public void draw(Batch batch, float parentAlpha) { validate(); Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); float currentY = getItemHeight(); for (ChatMessage item : items) { if (open.isDisabled()) { long ms = System.currentTimeMillis() - item.timeReceived; font.getColor().a = ms < FADE_MSG_MS ? 1 : 1f - (((float) (ms - FADE_MSG_MS)) / (HIDE_MSG_MS - FADE_MSG_MS)); } font.draw(batch, item.toString(), getX(), getY() + currentY); currentY += itemHeight; } font.getColor().a = 1; }
Example #3
Source File: GridRenderer.java From talos with Apache License 2.0 | 6 votes |
@Override public void draw (Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); batch.end(); shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix()); final float worldWidth = stage.getViewport().getWorldWidth() * camera.zoom; final float worldHeight = stage.getViewport().getWorldHeight() * camera.zoom; final Vector3 position = stage.getViewport().getCamera().position; float x = position.x - worldWidth / 2f; float y = position.y - worldHeight / 2f; shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); drawGrid(x, y, worldWidth, worldHeight); shapeRenderer.end(); batch.begin(); }
Example #4
Source File: Fish.java From libgdx-demo-pax-britannica with MIT License | 6 votes |
@Override public void draw(Batch batch) { super.draw(batch); delta = Math.min(0.06f, Gdx.graphics.getDeltaTime()); since_alive += delta/2.f; position.add((SPEED + random_speed) * delta * 5.f*random_direction,0); this.setPosition(position.x, position.y); if (since_alive < FADE_TIME) { super.setColor(1, 1, 1, Math.min((since_alive / FADE_TIME)*random_opacity,random_opacity)); } else { this.setColor(1, 1, 1, Math.min(1 - (since_alive - LIFETIME + FADE_TIME) / FADE_TIME, 1) * random_opacity); } if (since_alive > LIFETIME) { alive = false; } }
Example #5
Source File: AnimationSubView.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
@Override public void draw(Batch batch, float parentAlpha) { if (regions.size <= 0) return; GdxHelper.setBatchColor(batch, getColor(), parentAlpha); TextureRegion region = animation.getKeyFrame(stateTime); float rotation = getRotation(); if (rotation != 0) { batch.draw( region, getX(), getY(), getOriginX(), getOriginY(), region.getRegionWidth(), region.getRegionHeight(), 1, 1, rotation ); } else { batch.draw(region, getX(), getY(), region.getRegionWidth(), region.getRegionHeight()); } }
Example #6
Source File: NinePatchWidget.java From skin-composer with MIT License | 6 votes |
@Override public void draw(Batch batch, float x, float y, float width, float height) { if (widget.zoom == 1) { style.lightTile.draw(batch, x, y, width, height); } else { drawTiles(batch, x, y, width, height); } if (drawable != null) { drawDrawable(batch, x, y, width, height); } drawHandles(batch, x, y, width, height); drawBlackBars(batch, x, y, width, height); drawGrid(batch, x, y, width, height); drawBorder(batch, x, y, width, height); }
Example #7
Source File: Debris.java From libgdx-demo-pax-britannica with MIT License | 6 votes |
@Override public void draw(Batch batch) { super.draw(batch); delta = Math.min(0.06f, Gdx.graphics.getDeltaTime()); since_alive += delta; facing.rotate((SPEED + random_speed) * delta).nor(); position.add(facing.scl((SPEED + random_speed) * delta)); this.setPosition(position.x, position.y); if (since_alive < FADE_TIME) { super.setColor(1, 1, 1, Math.min((since_alive / FADE_TIME) * random_opacity, random_opacity)); } else { this.setColor(1, 1, 1, Math.min(1 - (since_alive - LIFETIME + FADE_TIME) / FADE_TIME, 1) * random_opacity); } if (since_alive > LIFETIME) { alive = false; this.setColor(1, 1, 1, 0); } }
Example #8
Source File: VisImageTextButton.java From vis-ui with Apache License 2.0 | 6 votes |
@Override public void draw (Batch batch, float parentAlpha) { updateImage(); Color fontColor; if (isDisabled() && style.disabledFontColor != null) fontColor = style.disabledFontColor; else if (isPressed() && style.downFontColor != null) fontColor = style.downFontColor; else if (isChecked() && style.checkedFontColor != null) fontColor = (isOver() && style.checkedOverFontColor != null) ? style.checkedOverFontColor : style.checkedFontColor; else if (isOver() && style.overFontColor != null) fontColor = style.overFontColor; else fontColor = style.fontColor; if (fontColor != null) label.getStyle().fontColor = fontColor; super.draw(batch, parentAlpha); if (focusBorderEnabled && drawBorder && style.focusBorder != null) style.focusBorder.draw(batch, getX(), getY(), getWidth(), getHeight()); }
Example #9
Source File: RenderWidget.java From Mundus with Apache License 2.0 | 6 votes |
@Override public void draw(Batch batch, float parentAlpha) { if (renderer == null || cam == null) return; // render part of the ui & pause rest batch.end(); vec.set(getOriginX(), getOriginY()); vec = localToStageCoordinates(vec); final int width = (int) getWidth(); final int height = (int) getHeight(); // apply widget viewport viewport.setScreenBounds((int) vec.x, (int) vec.y, width, height); viewport.setWorldSize(width * viewport.getUnitsPerPixel(), height * viewport.getUnitsPerPixel()); viewport.apply(); // render 3d scene renderer.render(cam); // re-apply stage viewport UI.INSTANCE.getViewport().apply(); // proceed ui rendering batch.begin(); }
Example #10
Source File: ThemeCard.java From Klooni1010 with GNU General Public License v3.0 | 6 votes |
@Override public void draw(Batch batch, float parentAlpha) { final float x = getX(), y = getY(); batch.setColor(theme.background); batch.draw(background, x, y, getWidth(), getHeight()); // Avoid drawing on the borders by adding +1 cell padding for (int i = 0; i < colorsUsed.length; ++i) { for (int j = 0; j < colorsUsed[i].length; ++j) { Cell.draw(theme.cellTexture, theme.getCellColor(colorsUsed[i][j]), batch, x + cellSize * (j + 1), y + cellSize * (i + 1), cellSize); } } super.draw(batch, parentAlpha); }
Example #11
Source File: ControlPanel.java From riiablo with Apache License 2.0 | 6 votes |
@Override public void draw(Batch batch, float a) { final float x = getX(); final float y = getY(); batch.draw(background, x, y); batch.draw(health, x + 30, y + 14); batch.draw(overlay, x + 28, y + 6); super.draw(batch, a); if (label.isVisible()) { label.setX(getX()); label.setText(Riiablo.string.format("panelhealth", (int) Riiablo.charData.getStats().get(Stat.hitpoints).toFloat(), (int) Riiablo.charData.getStats().get(Stat.maxhp).toFloat())); label.draw(batch, a); } }
Example #12
Source File: EffectCard.java From Klooni1010 with GNU General Public License v3.0 | 6 votes |
@Override public boolean showcase(Batch batch, float yDisplacement) { board.pos.y += yDisplacement; // If no effect is running if (board.effectsDone()) { // And we want to create a new one if (needCreateEffect) { // Clear at cells[1][1], the center one board.clearAll(1, 1, effect); needCreateEffect = false; } else { // Otherwise, the previous effect finished, so return false because we're done // We also want to draw the next time so set the flag to true setRandomPiece(); needCreateEffect = true; return false; } } board.draw(batch); return true; }
Example #13
Source File: VisWindow.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void draw (Batch batch, float parentAlpha) { if (keepWithinParent && getParent() != null) { float parentWidth = getParent().getWidth(); float parentHeight = getParent().getHeight(); if (getX() < 0) setX(0); if (getRight() > parentWidth) setX(parentWidth - getWidth()); if (getY() < 0) setY(0); if (getTop() > parentHeight) setY(parentHeight - getHeight()); } super.draw(batch, parentAlpha); }
Example #14
Source File: FontMetricsTool.java From riiablo with Apache License 2.0 | 5 votes |
@Override public void render() { Gdx.gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(); stage.draw(); Batch b = stage.getBatch(); b.begin(); GlyphLayout consolas16Layout = Riiablo.fonts.consolas16.draw(b, STRING, 0, 550, 600, center ? Align.center : Align.left, true); b.end(); PaletteIndexedBatch batch = Riiablo.batch; batch.begin(Riiablo.palettes.units); batch.setBlendMode(active.getBlendMode()); GlyphLayout otherLayout = active.draw(batch, STRING, 0, 250, 600, center ? Align.center : Align.left, true); batch.end(); if (debug) { ShapeRenderer shapes = Riiablo.shapes; shapes.begin(ShapeRenderer.ShapeType.Line); drawDebug(Riiablo.fonts.consolas16, consolas16Layout, 550); drawDebug(active, otherLayout, 250); shapes.end(); } }
Example #15
Source File: Countdown.java From libgdx-demo-pax-britannica with MIT License | 5 votes |
@Override public void draw(Batch batch) { delta = Math.min(0.06f, Gdx.graphics.getDeltaTime()); super.draw(batch); if (cnt < 1) { finished = true; this.setColor(1, 1, 1, 0); return; } if (showed) { fade = Math.min(fade + delta * 2.f, 1); } else { fade = Math.max(fade - delta * 2.f, 0); } this.setColor(1, 1, 1, fade); if (fade == 1) { showed = !showed; } if (fade == 0) { showed = !showed; --cnt; changeTexture(cnt); } }
Example #16
Source File: MatchOneState.java From Entitas-Java with MIT License | 5 votes |
@Override public void initialize() { entitas = new Entitas(); EntityIndexExtension.addEntityIndices(entitas); // Input World physics = engine.getManager(BasePhysicsManager.class).getPhysics(); BodyBuilder bodyBuilder = engine.getManager(BasePhysicsManager.class).getBodyBuilder(); Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera(); Batch batch = engine.getManager(BaseSceneManager.class).getBatch(); EmitInputSystem emitInputSystem = new EmitInputSystem(entitas.input, physics, camera ); systems .add(new ProcessInputSystem(entitas)) // Update .add(new GameBoardSystem(entitas.game)) .add(new FallSystem(entitas.game)) .add(new FillSystem(entitas.game)) .add(new ScoreSystem(entitas)) // Render .add(new RemoveViewSystem(entitas.game, physics)) .add(new AddViewSystem(entitas.game, assetsManager, bodyBuilder )) .add(new AnimatePositionSystem(entitas.game)) // Destroy .add(new DestroySystem(entitas.game)) .add(new RendererSystem(entitas, camera, batch, physics)) ; }
Example #17
Source File: MenuItem.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void draw (Batch batch, float parentAlpha) { Color fontColor; if (isDisabled() && style.disabledFontColor != null) fontColor = style.disabledFontColor; else if (isPressed() && style.downFontColor != null) fontColor = style.downFontColor; else if (isChecked() && style.checkedFontColor != null) fontColor = (isOver() && style.checkedOverFontColor != null) ? style.checkedOverFontColor : style.checkedFontColor; else if (isOver() && style.overFontColor != null) fontColor = style.overFontColor; else fontColor = style.fontColor; if (fontColor != null) label.getStyle().fontColor = fontColor; if (isDisabled()) shortcutLabel.getStyle().fontColor = style.disabledFontColor; else shortcutLabel.getStyle().fontColor = shortcutLabelColor; if (image != null && generateDisabledImage) { if (isDisabled()) image.setColor(Color.GRAY); else image.setColor(Color.WHITE); } super.draw(batch, parentAlpha); }
Example #18
Source File: ProfessionAbilityIcon.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); up.draw(batch, getX(), getY(), getWidth(), getHeight()); float progressValue = 1; if (cooldownEffect != null) { progressValue = 1 - ((float) cooldownEffect.getTurnCount()) / (float) cooldownEffect.totalTurnCount; } if (drawProgress) { progress.draw( batch, getX() + PROGRESS_OFFSET, getY() + PROGRESS_OFFSET, getWidth() - PROGRESS_OFFSET * 2, progressValue * (getHeight() - PROGRESS_OFFSET * 2) ); } if (listener.isPressed()) { down.draw(batch, getX(), getY(), getWidth(), getHeight()); } icon.draw( batch, getX()/* + getWidth() / 2 - icon.getMinWidth() / 2*/, getY()/* + getHeight() / 2 - icon.getMinHeight() / 2*/, getWidth()/*icon.getMinWidth()*/, getHeight()/*icon.getMinHeight()*/ ); }
Example #19
Source File: Draggable.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void draw (final Batch batch, final float parentAlpha) { if (actor != null) { LAST_POSITION.set(actor.getX(), actor.getY()); actor.setPosition(getX(), getY()); actor.draw(batch, getColor().a * parentAlpha); actor.setPosition(LAST_POSITION.x, LAST_POSITION.y); } }
Example #20
Source File: RendererSystem.java From Entitas-Java with MIT License | 5 votes |
public RendererSystem(CoreContext context, ShapeRenderer sr, Camera cam, Batch batch, BitmapFont font) { this.sr = sr; this.cam = cam; this.batch = batch; this.font = font; _group = context.getGroup(CoreMatcher.View()); _groupScore = context.getGroup(CoreMatcher.Score()); _groupTextureView = context.getGroup(CoreMatcher.TextureView()); }
Example #21
Source File: PatchGrid.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { if (!disabled && lineDragListener.isHovered() && !lineDragListener.isDragging()) { int screenX = Gdx.input.getX(); int screenY = Gdx.input.getY(); Vector2 localCoord = screenToLocalCoordinates(tmpVec2.set(screenX, screenY)); updateLinesHover(localCoord.x, localCoord.y); } if (!disabled) drawAreaGraphics(batch, parentAlpha); super.draw(batch, parentAlpha); drawGridNodes(batch, parentAlpha); }
Example #22
Source File: PausedLabel.java From martianrun with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); if (GameManager.getInstance().getGameState() == GameState.PAUSED) { font.drawWrapped(batch, Constants.PAUSED_LABEL, bounds.x, bounds.y, bounds.width, BitmapFont.HAlignment.CENTER); } }
Example #23
Source File: TabPane.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void drawLeftBorder(Batch batch) { Drawable leftBorder; if (selectedIndex == 0) { leftBorder = style.activeBorderLeftEdge; } else { leftBorder = style.inactiveBorderLeftEdge; } if (leftBorder != null) { leftBorder.draw(batch, getX(), getY() + contentHeight, headersLeftOffset, getHeight() - contentHeight); } }
Example #24
Source File: ParticleActor.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { effect.setPosition(getX(), getY()); Color c = getColor(); batch.setColor(c.r, c.g, c.b, c.a * parentAlpha); effect.draw(batch, Gdx.graphics.getDeltaTime()); if (effect.isComplete()) { ChangeListener.ChangeEvent event = Pools.obtain(ChangeListener.ChangeEvent.class); fire(event); Pools.free(event); } }
Example #25
Source File: ShaderImage.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void draw (Batch batch, float parentAlpha) { ShaderProgram originalShader = batch.getShader(); batch.setShader(shader); setShaderUniforms(shader); super.draw(batch, parentAlpha); batch.setShader(originalShader); }
Example #26
Source File: MundusSplitPane.java From Mundus with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { validate(); Color color = getColor(); applyTransform(batch, computeTransform()); // Matrix4 transform = batch.getTransformMatrix(); if (firstWidget != null) { getStage().calculateScissors(firstWidgetBounds, firstScissors); if (ScissorStack.pushScissors(firstScissors)) { if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a); batch.flush(); ScissorStack.popScissors(); } } if (secondWidget != null) { getStage().calculateScissors(secondWidgetBounds, secondScissors); if (ScissorStack.pushScissors(secondScissors)) { if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a); batch.flush(); ScissorStack.popScissors(); } } Drawable handle = style.handle; if (mouseOnHandle && isTouchable() && style.handleOver != null) handle = style.handleOver; batch.setColor(color.r, color.g, color.b, parentAlpha * color.a); handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height); resetTransform(batch); }
Example #27
Source File: GdxHelper.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public static void showStageEvents(final Stage stage) { EventListener listener = new EventListener() { private final Vector2 tmp = new Vector2(); private Actor actor = new Actor() { @Override public void draw(Batch batch, float parentAlpha) { if (target == null) return; batch.end(); Config.shapeRenderer.begin(ShapeRenderer.ShapeType.Line); Config.shapeRenderer.setProjectionMatrix(stage.getCamera().combined); Gdx.gl.glLineWidth(6); Config.shapeRenderer.setColor(Color.ORANGE); Vector2 pos = target.localToStageCoordinates(tmp.set(0, 0)); float x = pos.x, y = pos.y; Vector2 top = target.localToStageCoordinates(tmp.set(target.getWidth(), target.getHeight())); float maxX = top.x, maxY = top.y; Config.shapeRenderer.rect(x, y, maxX - x, maxY - y); Config.shapeRenderer.end(); batch.begin(); } }; { stage.addActor(actor); } public Actor target; @Override public boolean handle(Event event) { target = event.getTarget(); return false; } }; stage.addListener(listener); }
Example #28
Source File: FilteredTree.java From talos with Apache License 2.0 | 5 votes |
public void draw (Batch batch, float parentAlpha) { Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); if (style.background != null) style.background.draw(batch, getX(), getY(), getWidth(), getHeight()); draw(batch, rootNodes, leftColumnWidth); super.draw(batch, parentAlpha); // Draw actors. }
Example #29
Source File: ModuleBoardWidget.java From talos with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { batch.end(); shapeRenderer.setProjectionMatrix(getStage().getCamera().combined); Gdx.gl.glEnable(GL20.GL_BLEND); shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); drawCurves(); shapeRenderer.end(); batch.begin(); super.draw(batch, parentAlpha); }
Example #30
Source File: RenderedConsole.java From riiablo with Apache License 2.0 | 5 votes |
public void render(Batch b) { if (!visible || font == null) return; b.draw(modalBackground, 0, consoleY - 4, clientWidth, consoleHeight + 4); final int x = 2; String inputContents = in.getContents(); GlyphLayout glyphs = font.draw(b, BUFFER_PREFIX + inputContents, x, bufferY - 2); b.draw(cursorTexture, x, bufferY, clientWidth, 2); if (showCaret) { final int caret = in.getCaretPosition(); if (caret != in.length()) { glyphs.setText(font, BUFFER_PREFIX + inputContents.substring(0, caret)); } b.draw(cursorTexture, x + glyphs.width, consoleY - 2, 2, textHeight); } Pools.free(glyphs); final float outputOffset = scrollOffset * lineHeight; if (outputOffset < outputHeight) { // offsets output to always appear that it starts at top of console window scrollOffset = Math.max(scrollOffset, scrollOffsetMin); } float position = outputY; final int outputSize = OUTPUT.size; if (scrollOffset > outputSize) { scrollOffset = outputSize; position += ((scrollOffsetMin - scrollOffset) * lineHeight); } for (int i = scrollOffset - 1; i >= 0; i--) { if (position > clientHeight) break; String line = OUTPUT.get(i); font.draw(b, line, x, position); position += lineHeight; } }