List of usage examples for com.badlogic.gdx.graphics.glutils ShapeRenderer setProjectionMatrix
public void setProjectionMatrix(Matrix4 matrix)
From source file:com.mygdx.g3il.screens.MainMenuScreen.java
License:Apache License
@Override public void draw(float delta) { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update();/*from w w w. j a va2 s .c o m*/ ShapeRenderer shapeRenderer = new ShapeRenderer(); shapeRenderer.setProjectionMatrix(camera.combined); shapeRenderer.begin(ShapeRenderer.ShapeType.Line); shapeRenderer.setColor(1, 1, 0, 1); shapeRenderer.rect(playBounds.x, playBounds.y, playBounds.getWidth(), playBounds.getHeight()); shapeRenderer.rect(highscoresBounds.x, highscoresBounds.y, highscoresBounds.getWidth(), highscoresBounds.getHeight()); shapeRenderer.end(); game.batch.setProjectionMatrix(camera.combined); game.batch.setColor(Color.WHITE); game.batch.begin(); game.batch.disableBlending(); game.batch.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); game.batch.end(); game.batch.enableBlending(); game.batch.begin(); final Vector2 position = new Vector2(); drawText("Play", playBounds.getCenter(position)); drawText("High Scores", highscoresBounds.getCenter(position)); //drawText("Help", helpBounds.getCenter(position)); game.batch.end(); }
From source file:com.nebula2d.editor.framework.components.BoundingBox.java
License:Open Source License
@Override public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (gameObject != null && w > 0 && h > 0) { batcher.end();//from www .j a va 2s . c o m ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); shape.setColor(Color.RED); shape.begin(ShapeRenderer.ShapeType.Line); float halfw = w / 2.0f; float halfh = h / 2.0f; float x = gameObject.getPosition().x - halfw; float y = gameObject.getPosition().y - halfh; shape.rect(x, y, w, h); shape.end(); batcher.begin(); } }
From source file:com.nebula2d.editor.framework.components.Circle.java
License:Open Source License
@Override public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (gameObject != null && r % 360 != 0) { batcher.end();/*from w w w . j a va 2s . com*/ ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); shape.setColor(Color.RED); shape.begin(ShapeRenderer.ShapeType.Line); float x = gameObject.getPosition().x; float y = gameObject.getPosition().y; shape.circle(x, y, r); shape.end(); batcher.begin(); } }
From source file:com.nebula2d.editor.framework.GameObject.java
License:Open Source License
public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (renderer != null && renderer.isEnabled()) { renderer.render(selectedObject, batcher, cam); } else {//from w w w . ja v a 2 s .c o m batcher.end(); Gdx.gl.glEnable(GL20.GL_BLEND); ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); OrthographicCamera ortho = (OrthographicCamera) cam; shape.begin(ShapeRenderer.ShapeType.Filled); shape.setColor(new Color(0f, 1f, 0f, 0.5f)); shape.circle(getPosition().x, getPosition().y, 4 * ortho.zoom); shape.end(); Gdx.gl.glDisable(GL20.GL_BLEND); batcher.begin(); } for (IRenderable renderable : renderables) { if (((Component) renderable).isEnabled()) { renderable.render(selectedObject, batcher, cam); } } }
From source file:com.redthirddivision.astilade.utils.Debugger.java
License:Apache License
public static void drawBounds(ShapeRenderer sr, Rectangle bounds, Color color, OrthographicCamera camera) { if (Astilade.MAJOR_DEBUG) { sr.setProjectionMatrix(camera.combined); sr.begin(ShapeType.Line); sr.setColor(color);/*from www .ja va 2 s . c o m*/ sr.rect(bounds.x, bounds.y, bounds.width, bounds.height); sr.end(); } }
From source file:com.vlaaad.dice.ui.components.Rain.java
License:Open Source License
@Override public void draw(Batch batch, float parentAlpha) { validate();// w w w . j a v a 2 s . c o m batch.end(); Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); ShapeRenderer renderer = Config.shapeRenderer; renderer.setProjectionMatrix(batch.getProjectionMatrix()); renderer.setTransformMatrix(batch.getTransformMatrix()); renderer.begin(ShapeRenderer.ShapeType.Filled); renderer.setColor(style.color.r, style.color.g, style.color.b, style.color.a * parentAlpha); float usedWidth = getWidth() - style.pad; int count = (int) (usedWidth / (style.dropWidth + style.pad)); if (count == 0) return; float step = usedWidth / ((float) count); float x = style.pad; for (int i = 0, n = rows.size; i < n; i++) { Row row = rows.get(i); drawRow(x, row); x += step; } renderer.end(); Gdx.gl.glDisable(GL20.GL_BLEND); batch.begin(); }
From source file:core.september.pushathon.workers.BatchRenderer.java
License:Apache License
protected void renderMask(ShapeRenderer shape) { shape.setProjectionMatrix(camera.combined); shape.begin(ShapeType.Line);/*w w w .ja va 2 s. co m*/ shape.setColor(Color.DARK_GRAY); Rectangle boundsD = gameController.resources.counterD.getScaled(scale); shape.rect(boundsD.x, boundsD.y, boundsD.width * 2, boundsD.height); boundsD = gameController.resources.scoreU.getScaled(scale); shape.rect(boundsD.x, boundsD.y, boundsD.width * 4, boundsD.height); Gdx.gl.glLineWidth(5); shape.end(); }
From source file:ludowars.core.gui.LayerManager.java
public void render(SpriteBatch batch, ShapeRenderer sr, float delta) { for (Layer l : layers) { OrthographicCamera camera = l.getCamera(); camera.update();/* w w w . j a v a 2 s. c o m*/ batch.setProjectionMatrix(camera.combined); sr.setProjectionMatrix(camera.combined); batch.begin(); l.render(batch, sr, delta); batch.end(); } }
From source file:managers.HealthBarManager.java
public void drawHealthBar(ShapeRenderer sr, World world, Camera camera) { for (Entity e : world.getEntities(PLAYER, ENEMY)) { float x = e.get(Position.class).getX(); float y = e.get(Position.class).getY(); int eHeight = e.get(Body.class).getHeight(); sr.setColor(Color.BLACK); sr.begin(ShapeRenderer.ShapeType.Filled); sr.rect(x, y + eHeight + 9, (float) (e.get(Health.class).getMaxHp() / 2), 12); sr.setProjectionMatrix(camera.combined); sr.end();//w w w .j a v a 2s . com sr.setColor(Color.RED); sr.begin(ShapeRenderer.ShapeType.Filled); sr.rect(x, y + eHeight + 10, (float) (e.get(Health.class).getMaxHp() / 2), 10); sr.setProjectionMatrix(camera.combined); sr.end(); sr.setColor(Color.GREEN); sr.begin(ShapeRenderer.ShapeType.Filled); sr.rect(x, y + eHeight + 10, e.get(Health.class).getHp() / 2, 10); sr.setProjectionMatrix(camera.combined); sr.end(); } }
From source file:org.tntstudio.core.Screen.java
License:Apache License
@Override public void vpApply(ShapeRenderer shape) { if (shape == null) return;/*from w ww.ja va 2 s .c o m*/ shape.setProjectionMatrix(projection); shape.setTransformMatrix(transform); }