/** Draws the debug rects for the specified actor and any children, recursively. */ public void draw(Actor actor) { if (disabled) return; shapes.setProjectionMatrix(stage.getCamera().projection); shapes.setTransformMatrix(stage.getCamera().view); shapes.begin(ShapeType.Line); drawRecursive(actor); shapes.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(); }
public void drawDebug(SpriteBatch batch) { batch.end(); ShapeRenderer renderer = DebugRendererManager.instance.debugRenderer; renderer.setProjectionMatrix(batch.getProjectionMatrix()); renderer.setTransformMatrix(batch.getTransformMatrix()); renderer.translate(getX(), getY(), 0); renderer.begin(ShapeRenderer.ShapeType.Line); renderer.setColor(new Color(Color.RED)); renderer.rect(0, 0, getWidth(), getHeight()); renderer.end(); batch.begin(); }
private void renderBox(Body body, float halfWidth, float halfHeight) { // get the bodies center and angle in world coordinates Vector2 pos = body.getWorldCenter(); float angle = body.getAngle(); // set the translation and rotation matrix transform.setToTranslation(pos.x, pos.y, 0); transform.rotate(0, 0, 1, (float) Math.toDegrees(angle)); // render the box renderer.begin(ShapeType.Line); renderer.setTransformMatrix(transform); renderer.setColor(1, 1, 1, 1); renderer.rect(-halfWidth, -halfHeight, halfWidth * 2, halfHeight * 2); renderer.end(); }
@Override public void draw(Batch batch, float parentAlpha) { batch.draw( reorganize.get(), parent.getX() + reorganizePos.x, parent.getY() + reorganizePos.y, reorganizePos.width, reorganizePos.height); batch.draw( newMilitary.get(), parent.getX() + newMilitaryPos.x, parent.getY() + newMilitaryPos.y, newMilitaryPos.width, newMilitaryPos.height); batch.draw( recruit.get(), parent.getX() + recruitPos.x, parent.getY() + recruitPos.y, recruitPos.width, recruitPos.height); batch.draw( training.get(), parent.getX() + trainingPos.x, parent.getY() + trainingPos.y, trainingPos.width, trainingPos.height); batch.draw( merge.get(), parent.getX() + mergePos.x, parent.getY() + mergePos.y, mergePos.width, mergePos.height); batch.draw( disband.get(), parent.getX() + disbandPos.x, parent.getY() + disbandPos.y, disbandPos.width, disbandPos.height); batch.draw( upgrade.get(), parent.getX() + upgradePos.x, parent.getY() + upgradePos.y, upgradePos.width, upgradePos.height); for (TextWidget<ArchitectureCommandFrame.TextType> textWidget : textWidgets) { textWidget.setPosition( textWidget.getExtra().position.x + parent.getX(), textWidget.getExtra().position.y + parent.getY()); if (textWidget.getExtra().staticText) { textWidget.setText(textWidget.getExtra().name); } else { textWidget.setText( parent.getCurrentArchitecture().getFieldString(textWidget.getExtra().name)); } textWidget.draw(batch, parentAlpha); } if (militaryBottomPane == null) { initMilitaryBottomPane(); } if (militaryTopPane == null) { initMilitaryTopPane(); } if (currentMilitary != null) { batch.end(); shapeRenderer.begin(ShapeRenderer.ShapeType.Line); shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix()); shapeRenderer.setTransformMatrix(batch.getTransformMatrix()); shapeRenderer.setColor(selectedBorderColor); shapeRenderer.rect( parent.getX() + currentMilitaryPos.getX(), parent.getY() + currentMilitaryPos.getY(), currentMilitaryPos.getWidth(), currentMilitaryPos.getHeight()); shapeRenderer.end(); batch.begin(); } }
@Override protected void drawChildren(Batch batch, float parentAlpha) { shapeRenderer.setTransformMatrix(batch.getTransformMatrix()); shapeRenderer.rect(0, 0, getWidth(), getHeight()); }