private void drawCullingRectangles(ShapeRenderer shapeRenderer, Color color) { for (BoundingBox br : boundingBoxes) { Rectangle r = br.rectangle; Rectangle cullingArea = getCullingArea(tmpRectangle, r, angleRad, position, scale); shapeRenderer.set(ShapeRenderer.ShapeType.Filled); Color fillColor = tmpColor.set(color); fillColor.a *= 0.25f; shapeRenderer.setColor(fillColor); shapeRenderer.rect(cullingArea.x, cullingArea.y, cullingArea.width, cullingArea.height); tmp.set(r.x, r.y).rotateRad(angleRad).add(position); tmp1.set(r.x + r.width, r.y).rotateRad(angleRad).add(position); tmp2.set(r.x + r.width, r.y + r.height).rotateRad(angleRad).add(position); tmp3.set(r.x, r.y + r.height).rotateRad(angleRad).add(position); shapeRenderer.set(ShapeRenderer.ShapeType.Line); shapeRenderer.setColor(color); shapeRenderer.line(tmp, tmp1); shapeRenderer.line(tmp1, tmp2); shapeRenderer.line(tmp2, tmp3); shapeRenderer.line(tmp3, tmp); } }
public void update(float delta) { Entity playerEntity = player.get(0); PlayerSteerableComponent psc = cmpsc.get(playerEntity); for (int i = 0; i < entities.size(); i++) { Entity entity = entities.get(i); TalkComponent tc = cmtc.get(entity); NonControllablePersonSteerableComponent ncpstc = cmstc.get(entity); if (ncpstc.x - 160 < psc.getPosition().x && psc.getPosition().x < ncpstc.x + 160 && ncpstc.y - 210 < psc.getPosition().y && psc.getPosition().y < ncpstc.y + 210) { layout.setText(font, tc.textToSay); float x = ncpstc.x - (layout.width / 2); float y = ncpstc.y + layout.height + 15; batch.end(); shapeRenderer.setProjectionMatrix(TwoD.getMain().camera.combined); shapeRenderer.begin(ShapeType.Filled); shapeRenderer.setColor(Color.WHITE); shapeRenderer.rect(x - 13, y + 2, 26 + layout.width, 26 + layout.height); shapeRenderer.setColor(Color.BLACK); shapeRenderer.rect(x - 10, y + 5, 20 + layout.width, 20 + layout.height); shapeRenderer.end(); batch.begin(); font.draw(batch, layout, x, y + 25); } } }
private void renderHP() { ShapeRenderer render = new ShapeRenderer(); int hp = world.thePlayer.hp; if (hp >= 50) render.setColor(0.0f, 1.0f, 0.0f, 1); else if (hp > 33) render.setColor(1.0f, 1.0f, 0.0f, 1); else if (hp > 0) render.setColor(1.0f, 0.0f, 0.0f, 1); if (!(hp < 33)) { render.begin(ShapeRenderer.ShapeType.FilledRectangle); render.filledRect(5, 5, hp * 2, 20); render.end(); } if (flickerDraw && (hp < 33)) { render.begin(ShapeRenderer.ShapeType.FilledRectangle); render.filledRect(5, 5, hp * 2, 20); render.end(); flickerDraw = false; } else if (lastFlicker > 3) { flickerDraw = true; this.lastFlicker = 0; } else this.lastFlicker++; }
public void render(SpriteBatch sb, ShapeRenderer sr) { double drawx = getDrawX(); double drawy = getDrawY(); if (drawx < -40 || drawx > Gdx.graphics.getWidth() + 40) return; if (drawy < -40 || drawy > Gdx.graphics.getHeight() + 40) return; Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); float red = Math.min(1f, 2f * (1f - health / maxHealth)); float green = Math.min(1f, 2f * (health / maxHealth)); sr.setColor(red * 0.75f, green * 0.75f, 0, 0.9f); draw(sb, sr, 20, ShapeType.Filled); sr.setColor(red, green, 0, 1f); draw(sb, sr, 20, ShapeType.Line); sr.begin(ShapeType.Filled); sr.circle((float) getDrawX(), (float) getDrawY(), 2); sr.end(); Gdx.gl.glDisable(GL20.GL_BLEND); if (!arms.isEmpty() && arms.getFirst() != null) arms.getFirst().render(sb, sr); // if(isAI) { // float barWidth = 60; // sr.begin(ShapeType.Filled); // float red = Math.min(1f, 2f * (1f - health / maxHealth)); // float green = Math.min(1f, 2f * (health / maxHealth)); // sr.setColor(red, green, 0, 1f); // sr.rect((float) getDrawX() - barWidth / 2, (float) getDrawY() + 30, (float) (barWidth * // health / maxHealth), 5); // sr.end(); // } }
@Override public void render() { gl.glClear(GL10.GL_COLOR_BUFFER_BIT); spriteBatch.setProjectionMatrix(worldCamera.projection); spriteBatch.setTransformMatrix(worldCamera.view); spriteBatch.begin(); farmSprite.draw(spriteBatch); spriteBatch.end(); shapeRenderer.setProjectionMatrix(worldCamera.projection); shapeRenderer.setTransformMatrix(worldCamera.view); shapeRenderer.setColor(1f, 1f, 1f, 1f); shapeRenderer.begin(ShapeType.Line); for (int i = 0; i < convexHull2d.getPointsCount(); i++) { float x0 = convexHull2d.getX(i); float y0 = convexHull2d.getY(i); if (i + 1 == convexHull2d.getPointsCount()) { float x1 = convexHull2d.getX(0); float y1 = convexHull2d.getY(0); shapeRenderer.line(x0, y0, x1, y1); break; } float x1 = convexHull2d.getX(i + 1); float y1 = convexHull2d.getY(i + 1); shapeRenderer.line(x0, y0, x1, y1); } shapeRenderer.end(); shapeRenderer.setColor(0f, 1f, 1f, 1f); shapeRenderer.begin(ShapeType.Line); for (int i = 0; i < smallConvexHull2d.getPointsCount(); i++) { float x0 = smallConvexHull2d.getX(i); float y0 = smallConvexHull2d.getY(i); if (i + 1 == smallConvexHull2d.getPointsCount()) { float x1 = smallConvexHull2d.getX(0); float y1 = smallConvexHull2d.getY(0); shapeRenderer.line(x0, y0, x1, y1); break; } float x1 = smallConvexHull2d.getX(i + 1); float y1 = smallConvexHull2d.getY(i + 1); shapeRenderer.line(x0, y0, x1, y1); } shapeRenderer.end(); shapeRenderer.setColor(1f, 0f, 0f, 1f); shapeRenderer.begin(ShapeType.FilledCircle); for (int i = 0; i < convexHull2d.getPointsCount(); i++) { float x = convexHull2d.getX(i); float y = convexHull2d.getY(i); shapeRenderer.filledCircle(x, y, 1f, 5); } shapeRenderer.end(); }
@Override public void drawShape(ShapeRenderer shapes) { if (state == State.Growing) { shapes.setColor(0.0f, 1.0f, 0.0f, 1.0f); } else if (state == State.Dead) { float color = nutrition / (nutrition_max * age / max_life); shapes.setColor(color, color, 0.0f, 1.0f); } super.drawShape(shapes); }
@Override public void render(ShapeRenderer renderer, Transform transform) { tmp.set(renderer.getColor()); renderer.setColor(color); renderer.circle( transform.x + (centre ? 0 : +radius) + ox, transform.y + (centre ? 0 : +radius) + oy, radius, segments); renderer.setColor(tmp); }
public void render() { shapeRenderer.begin(ShapeType.FilledRectangle); shapeRenderer.setColor(color); shapeRenderer.filledRect(x, y, width, height); shapeRenderer.end(); shapeRenderer.begin(ShapeType.FilledCircle); shapeRenderer.setColor(1.0f, 0.0f, 0.0f, 1.0f); shapeRenderer.filledCircle(x, y, 3); shapeRenderer.end(); }
protected void process(Entity e) { if (pm.has(e)) { Position position = pm.getSafe(e); Gdx.gl.glEnable(GL10.GL_BLEND); Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); // Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); if (cm.has(e)) { Circle circle = cm.getSafe(e); if (circle.filled) { shapeRenderer.begin(ShapeType.Filled); } else { shapeRenderer.begin(ShapeType.Line); } if (circle.borderSize > 0) { shapeRenderer.setColor(circle.borderColor); shapeRenderer.circle(position.x, position.y, circle.radius, circle.segments); shapeRenderer.setColor(circle.color); shapeRenderer.circle( position.x, position.y, circle.radius - circle.borderSize, circle.segments); } else { shapeRenderer.setColor(circle.color); shapeRenderer.circle(position.x, position.y, circle.radius, circle.segments); } shapeRenderer.end(); } if (rm.has(e)) { Rectangle rectangle = rm.getSafe(e); shapeRenderer.setColor(rectangle.color); if (rectangle.filled) { shapeRenderer.begin(ShapeType.Filled); } else { shapeRenderer.begin(ShapeType.Line); } shapeRenderer.rect(position.x, position.y, rectangle.width, rectangle.height); shapeRenderer.end(); } Gdx.gl.glDisable(GL10.GL_BLEND); Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH); } }
private void renderShrine(ShapeRenderer shapes, SpriteBatch batch) { batch.end(); // 2. clear our depth buffer with 1.0 Gdx.gl.glClearDepthf(1f); Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT); // 3. set the function to LESS Gdx.gl.glDepthFunc(GL20.GL_LESS); // 4. enable depth writing Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); // 5. Enable depth writing, disable RGBA color writing Gdx.gl.glDepthMask(true); Gdx.gl.glColorMask(false, false, false, false); // 6. render your primitive shapes shapes.begin(ShapeType.Filled); // TODO: remove setColor if not needed. shapes.setColor(1f, 0f, 0f, 0.5f); // shapes.circle(200, 200, 100); shapes.setColor(0f, 1f, 0f, 0.5f); // shapes.rect(200, 200, 100, 100); shapes.rect(-300, 0, 600, 500); shapes.rect(100, 100, 100, 100); shapes.end(); batch.begin(); // 8. Enable RGBA color writing // (SpriteBatch.begin() will disable depth mask) Gdx.gl.glColorMask(true, true, true, true); // 9. Make sure testing is enabled. Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); // 10. Now depth discards pixels outside our masked shapes Gdx.gl.glDepthFunc(GL20.GL_EQUAL); shrineOff.render(batch); shrineOn.setAlpha(shrineGlowAlpha); shrineOn.render(batch); batch.end(); Gdx.gl.glDepthFunc(GL20.GL_ALWAYS); batch.begin(); }
private void drawWeapon() { shapeRenderer.begin(ShapeType.Line); Player player = GameController.getInstance().getPlayer(); float offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_RIGHT; float offsetY = Constants.WEAPON_OFFSET_FROM_PLAYER_Y; if (player.getFacing() == 0) { offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_RIGHT; } else { offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_LEFT; } Player p = player; Float deltaX = 0f; Float deltaY = 0f; Float playerXCentered = p.getX() + (p.getWidth() / 2); Float playerYCentered = p.getY() + (p.getHeight() / 2); Float mouseX = p.getTargetX(); Float mouseY = p.getTargetY(); deltaX = (mouseX - playerXCentered); deltaY = (mouseY - playerYCentered); Double angle = Math.atan2(deltaY.doubleValue(), deltaX.doubleValue()); Double rotation = (Math.toDegrees(angle)); float x = player.getX() + offsetX; float y = player.getY() + offsetY; shapeRenderer.setColor(Color.ORANGE); shapeRenderer.rect( x, y, Constants.WEAPON_ORIGIN_X, Constants.WEAPON_ORIGIN_Y, Constants.WEAPON_WIDTH, Constants.WEAPON_HEIGHT, 1, player.getFacing() == 0 ? 1 : -1, rotation.intValue()); shapeRenderer.setColor(Color.BLACK); shapeRenderer.circle(x + Constants.WEAPON_ORIGIN_X, y + Constants.WEAPON_ORIGIN_Y, 2); shapeRenderer.end(); }
@Override public void renderAffine2(ShapeRenderer renderer, Transform transform) { tmp.set(renderer.getColor()); renderer.setColor(color); affine2.set(transform.affine2); affine2.translate(ox, oy); if (!centre) { affine2.translate(radius, radius); } tmpV2.set(0, 0); affine2.applyTo(tmpV2); renderer.circle(tmpV2.x, tmpV2.y, radius, segments); renderer.setColor(tmp); }
private void drawTrajectory() { float offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_RIGHT; float offsetY = Constants.WEAPON_OFFSET_FROM_PLAYER_Y; if (player.getFacing() == 0) { offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_RIGHT; } else { offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_LEFT; } Player p = player; Float originX = p.getX() + offsetX + Constants.WEAPON_ORIGIN_X; Float originY = p.getY() + offsetY + Constants.WEAPON_ORIGIN_Y; Float mouseX = player.getTargetX(); Float mouseY = player.getTargetY(); Float deltaX = (mouseX - originX); Float deltaY = (mouseY - originY); Double angle = Math.atan2(deltaY.doubleValue(), deltaX.doubleValue()); Float x = (float) Math.cos(angle.floatValue()); Float y = (float) Math.sin(angle.floatValue()); Float calculatedX = originX + x * Constants.SHOT_DISTANCE_FROM_ORIGIN; Float calculatedY = originY + y * Constants.SHOT_DISTANCE_FROM_ORIGIN; shapeRenderer.begin(ShapeType.Line); shapeRenderer.setColor(Color.RED); shapeRenderer.line(calculatedX, calculatedY, mouseX, mouseY); shapeRenderer.end(); }
/** Renders a blue rectangle showing the field of view of the closeup camera */ public void render(ShapeRenderer renderer) { if (!inCloseupMode) { // Figure out the location of the camera corners in the world Vector2 bottomLeft = myUnproject(closeupCamera, 0, closeupCamera.viewportHeight); Vector2 bottomRight = myUnproject(closeupCamera, closeupCamera.viewportWidth, closeupCamera.viewportHeight); Vector2 topRight = myUnproject(closeupCamera, closeupCamera.viewportWidth, 0); Vector2 topLeft = myUnproject(closeupCamera, 0, 0); // Draw a rectangle showing the closeup camera's field of view renderer.begin(ShapeType.Line); renderer.setColor(Color.BLUE); float[] poly = { bottomLeft.x, bottomLeft.y, bottomRight.x, bottomRight.y, topRight.x, topRight.y, topLeft.x, topLeft.y }; renderer.set(ShapeType.Line); renderer.polygon(poly); renderer.end(); } }
@Override public void render(float arg0) { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update(); if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { if (focused) { focused = false; } else { goBack(); } } if (focused) { shapeRenderer.begin(ShapeType.FilledRectangle); Color c = new Color(0.15f, 0.4f, 0.15f, 1f); shapeRenderer.setColor(c); shapeRenderer.filledRect(focusedBox.x, focusedBox.y, focusedBox.width, focusedBox.height); shapeRenderer.end(); } batch.begin(); ObjectMap.Entries<String, Rectangle> it = bindingButtons.entries(); // draw back button text font.draw(batch, "Back", backButton.x, backButton.y + backButton.height); // draw option texts while (it.hasNext()) { ObjectMap.Entry<String, Rectangle> entry = it.next(); Rectangle bounds = entry.value; font.draw(batch, entry.key, bounds.x, bounds.y + bounds.height); Binding binding = game.getBindings().get(entry.key); font.draw(batch, binding.character, bounds.x + 200.0f, bounds.y + bounds.height); } batch.end(); }
public void render(float delta) { gameTicks++; long seconds = (long) ((gameTicks / 60D) * 10L); Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1); Gdx.gl.glClear(Gdx.gl.GL_COLOR_BUFFER_BIT); controller.update(delta); updateEntities(delta); renderer.render(); button.begin(ShapeRenderer.ShapeType.Filled); { if (Gdx.app.getType().equals(Application.ApplicationType.Android)) { Gdx.gl.glEnable(Gdx.gl20.GL_BLEND); Gdx.gl.glBlendFunc(Gdx.gl20.GL_SRC_ALPHA, Gdx.gl20.GL_ONE_MINUS_SRC_ALPHA); button.setColor(0.0F, 0.5F, 0.5F, 0.5F); button.rect(left.x, left.y, left.width, left.height); button.rect(right.x, right.y, right.width, right.height); button.setColor(1.0F, 1.0F, 1.0F, 0.5F); button.rect(jump.x, jump.y, jump.width, jump.height); } world.getJaxon().inventory.renderGUI(button, width, height, buttonSize * 0.75F); } button.end(); batch.begin(); { if (Gdx.app.getType().equals(Application.ApplicationType.Android)) { batch.draw(controlLeft, left.x, left.y, left.width, left.height); batch.draw(controlRight, right.x, right.y, right.width, right.height); batch.draw(controlUp, jump.x, jump.y, jump.width, jump.height); } world.getJaxon().inventory.renderItems(batch, width, height, buttonSize * 0.75F); font.draw( batch, "Time: " + (seconds / 10D) + " ticks, FPS: " + Gdx.graphics.getFramesPerSecond(), 0, height - 10); } batch.end(); }
@Override public void render(final float deltaTime) { // Sets the clear color Gdx.gl.glClearColor(0, 0, 0, 1); // Clears the screen Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Gets the x position of the camera, clamping it if out of bounds camera.position.x = MathUtils.clamp( worldManager.player.getPosition().x, camera.viewportWidth / 2f, worldManager.mapWidth - (camera.viewportWidth / 2f)); // Updates the camera camera.update(); // Renders the world worldManager.render(game.batch, camera, deltaTime); // Updates the input updateInput(); // Sets the world (applies the cycle's physics to the bodies) worldManager.step(deltaTime); // Renders the debugging mouse info, don't worry about it if (originVector != null) { Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); shapeRenderer.begin(ShapeRenderer.ShapeType.Line); shapeRenderer.setColor(0.5f, 0.5f, 0, 0.5f); shapeRenderer.line( originVector.x - ControlListener.MIN_X_DISTANCE, 0, originVector.x - ControlListener.MIN_X_DISTANCE, Gdx.graphics.getHeight()); shapeRenderer.line( originVector.x + ControlListener.MIN_X_DISTANCE, 0, originVector.x + ControlListener.MIN_X_DISTANCE, Gdx.graphics.getHeight()); shapeRenderer.setColor(0, 0.5f, 0.5f, 0.5f); shapeRenderer.circle( originVector.x, Gdx.graphics.getHeight() - originVector.y, ControlListener.ORIGIN_MAX_DISTANCE); shapeRenderer.end(); Gdx.gl.glDisable(GL20.GL_BLEND); } }
private void drawProgress() { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); renderer.setColor(Color.ORANGE); renderer.begin(ShapeType.Filled); renderer.rect(0, 0, 800, 600); renderer.end(); }
private void drawTriangleStrips(ShapeRenderer shapeRenderer, Color color, Color color1) { for (int i = 0; i < vertexDataArray.size; i++) { StripVertex bb = vertexDataArray.items[i]; Array<Float> data = bb.insideVertexData; for (int j = 0; j < data.size - 3; ) { shapeRenderer.setColor(j == 0 ? color : color1); tmp.x = data.items[j]; tmp.y = data.items[j + 1]; tmp.rotateRad(angleRad); tmp.scl(scale); tmp.add(position); tmp1.x = data.items[j + 3]; tmp1.y = data.items[j + 4]; tmp1.rotateRad(angleRad); tmp1.scl(scale); tmp1.add(position); j += 3; shapeRenderer.line(tmp, tmp1); } data = bb.outsideVertexData; for (int j = 0; j < data.size - 3; ) { shapeRenderer.setColor(j == 0 ? Color.ORANGE : Color.RED); tmp.x = data.items[j]; tmp.y = data.items[j + 1]; tmp.rotateRad(angleRad); tmp.scl(scale); tmp.add(position); tmp1.x = data.items[j + 3]; tmp1.y = data.items[j + 4]; tmp1.rotateRad(angleRad); tmp1.scl(scale); tmp1.add(position); j += 3; shapeRenderer.line(tmp, tmp1); } } }
public static void drawPoint(Vector2 point, View view, Color color) { ShapeRenderer shapeRenderer = view.getShapeRenderer(); shapeRenderer.set(ShapeRenderer.ShapeType.Filled); shapeRenderer.setColor(color); float w, h; w = h = 5 * view.getCamera().zoom; shapeRenderer.rect(point.x - w / 2, point.y - h / 2, w, h); }
public GameMap() { // tiles = new Array<Vector2>(); sr = new ShapeRenderer(); sr.setColor(Color.MAGENTA); LoadMap(); }
private void drawCircles(OrthographicCamera camera) { shapeRenderer.setProjectionMatrix(camera.projection); shapeRenderer.begin(ShapeType.Line); shapeRenderer.setColor(Color.ORANGE); shapeRenderer.circle(mouseX - 300f, Constants.CAMERA_HEIGHT - mouseY - 300f, 10); shapeRenderer.end(); shapeRenderer.setProjectionMatrix(camera.combined); }
private void drawRectangles() { shapeRenderer.begin(ShapeType.Line); Player player = GameController.getInstance().getPlayer(); float x = player.getX(); float y = player.getY(); shapeRenderer.setColor(Color.GREEN); shapeRenderer.rect(x, y, player.getWidth(), player.getHeight()); shapeRenderer.end(); }
public void render(SpriteBatch sb, ShapeRenderer sr, Point location) { Color color; if (!enabled) color = new Color(0.533f, 0.533f, 0.533f, 1f); else if (selected) color = new Color(0.533f, 0.533f, 0.8f, 1f); else color = new Color(0.133f, 0.133f, 0.8f, 1f); float border = 5f, height = 20f; Rectangle size = parent.getDefaultSize(); sr.begin(ShapeType.Filled); // Draw track sr.setColor(Color.BLACK); sr.rect(location.x - 2.5f, location.y - 2.5f, size.width + 5, 25); sr.setColor(color); sr.rect(location.x, location.y, size.width, 20); // Draw slider float cx = location.x + size.width * Math.min(1f * step * val, maxVal - minVal) / (maxVal - minVal); float width_ptr = 20f, height_ptr = 30f; sr.setColor(Color.BLACK); sr.rect( cx - (border + width_ptr) / 2f, location.y - (height_ptr - height + border) / 2f, width_ptr + border, height_ptr + border); sr.setColor(0.133f, 0.133f, 0.8f, 1f); sr.rect(cx - width_ptr / 2f, location.y - (height_ptr - height) / 2f, width_ptr, height_ptr); sr.end(); // Label String label = "" + Math.min(val * step + minVal, maxVal); BitmapFont font = Root.getFont(24); TextBounds lBound = font.getBounds(label); float width_t = lBound.width; sb.begin(); if (!label.isEmpty()) { font.draw(sb, label, location.x - width_t - 20, location.y + height); } sb.end(); }
@Override public void render(ShapeRenderer renderer, Transform transform) { tmp.set(renderer.getColor()); renderer.setColor(color); // TODO rotation? float x = ox + (centre ? -width / 2f : 0); float y = oy + (centre ? -height / 2f : 0); renderer.rect( transform.x + x, transform.y + y, x + originX, y + originY, width, height, 1, 1, transform.rotation); renderer.setColor(tmp); }
public static void drawPoint2Point(Vector2 pos1, Vector2 pos2) { shapeRenderer.setProjectionMatrix(camera.combined); shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); shapeRenderer.setColor(0, 0, 1, 1); shapeRenderer.circle(pos1.x, pos1.y, 5); shapeRenderer.circle(pos2.x, pos2.y, 5); // shapeRenderer.line(pos1, pos2, 10); shapeRenderer.rectLine(pos1, pos2, 3); shapeRenderer.end(); }
public void drawSelectedTile() { if (selectedTile.getX() != -1) { shapeRenderer.setColor(Color.RED); shapeRenderer.rect( selectedTile.getX() * Game.BLOCK_WIDTH, selectedTile.getY() * Game.BLOCK_HEIGHT, Game.BLOCK_WIDTH + Game.TILE_OFFSET, Game.BLOCK_HEIGHT + Game.TILE_OFFSET); } }
@Override public void draw(SpriteBatch batch, float parentAlpha) { shapeRenderer.setProjectionMatrix(getStage().getCamera().combined); batch.end(); shapeRenderer.begin(ShapeType.Circle); shapeRenderer.setColor(shapeFillColor); shapeRenderer.circle(getX(), getY(), 20); shapeRenderer.end(); batch.begin(); }
/** * Draws a filled rectangle using a <code>ShapeRenderer</code>.<br> * IMPORTANT: Don't forget to set the <code>ShapeRenderer</code>'s projection matrix with {@link * #setShapeRendererProjectionMatrix(Matrix4)}! * * @param batch - Since drawing is done with a <code>ShapeRenderer</code>, the active batch should * be passed to this method to end/start it. */ public static void fillRect(SpriteBatch batch, float x, float y, float w, float h, Color c) { batch.end(); Gdx.gl.glEnable(GL20.GL_BLEND); shapes_.begin(ShapeType.Filled); shapes_.setColor(c); shapes_.rect(x, y, w, h); shapes_.end(); Gdx.gl.glDisable(GL20.GL_BLEND); batch.begin(); }
/** * Draws an outline of a rectangle using a <code>ShapeRenderer</code>.<br> * IMPORTANT: Don't forget to set the <code>ShapeRenderer</code>'s projection matrix with {@link * #setShapeRendererProjectionMatrix(Matrix4)}! * * @param batch - Since drawing is done with a <code>ShapeRenderer</code>, the active batch should * be passed to this method to end/start it. */ public static void drawLine(SpriteBatch batch, float x1, float y1, float x2, float y2, Color c) { batch.end(); Gdx.gl.glEnable(GL20.GL_BLEND); shapes_.begin(ShapeType.Line); shapes_.setColor(c); shapes_.line(x1, y1, x2, y2); shapes_.end(); Gdx.gl.glDisable(GL20.GL_BLEND); batch.begin(); }