Make invisible body line box2d libgdx

I want to make these body lines invisible, because it’s a lot that was left in the games, and that body circle too. The squares are of a layer tiled map. The circle is a body of a sprite.

Classes draw tiled map

package com.mygdx.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.maps.MapObject;
import com.badlogic.gdx.maps.objects.RectangleMapObject;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.math.Rectangle;

import com.badlogic.gdx.physics.box2d.World;

public class B2CriaMundo {
	public B2CriaMundo(World mundo, TiledMap mapa) {
			
		
		for(MapObject obj : mapa.getLayers().get(1).getObjects().getByType(RectangleMapObject.class)) {
			Rectangle rect = ((RectangleMapObject) obj).getRectangle();
			
			new Meteoro(mundo, mapa, rect);
			
		}
	}
	
	public static void batida() {
		Gdx.app.log("Bateu:", "");
	}
}

package com.mygdx.game;

import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.World;

public class Meteoro extends ObjetoInterativo{
	public Meteoro(World mundo, TiledMap mapa, Rectangle bounds) {
		super(mundo, mapa, bounds);
		fixture.setUserData(this);
	}

}

package com.mygdx.game;

import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTile;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;

public abstract class ObjetoInterativo {
	protected World mundo;
	protected TiledMap mapa;
	protected TiledMapTile titulo;
	protected Rectangle bounds;
	protected Body corpo;
	protected Fixture fixture;
	
	public ObjetoInterativo(World mundo, TiledMap mapa, Rectangle bounds) {
		this.mundo = mundo;
		this.mapa = mapa;
		this.bounds = bounds;
		
		BodyDef corpoDef = new BodyDef();
		FixtureDef fdef = new FixtureDef();
		PolygonShape shape = new PolygonShape();
		
		
		corpoDef.type = BodyDef.BodyType.StaticBody;
		corpoDef.position.set((bounds.getX() + bounds.getWidth() /2) / ExGame.PPM, (bounds.getY() + bounds.getHeight() /2) / ExGame.PPM);
		
		corpo = mundo.createBody(corpoDef);
		
		shape.setAsBox(bounds.getWidth() /2 / ExGame.PPM, bounds.getHeight() /2 / ExGame.PPM);
		fdef.shape = shape;
		fixture = corpo.createFixture(fdef);
	}
	
}

Are you using the debug renderer to draw these outlines?

You should only use the debug renderer for debugging, maybe use a key to toggle it on / off.

i’am drawing just a tiledmap like world, rectangles appear alone.

Can you show your render code please

Hey everyone who forget his post or to the new persons. I being looking for this answer a lot. I didn’t find it anywhere, but I know found the answer.

When you Make the instance of the Box2DDebugRenderer you should then use the void method setDrawBodies() to false. A show you a little example:

//Box2d variables
private World world;
private Box2DDebugRenderer b2dr; //Represent all the fetures and bodies indside our 2Dbox World

//Instance of the new World and a new Box2DDebugRenderer
world = new World(new Vector2(0,-10),true);
b2dr = new Box2DDebugRenderer();
b2dr.setDrawBodies(false); //This method set the body lines to invisible

I hope this could work for everyone who has looking for the answer.

Regards.

Why using the Box2DDebugRenderer at all, when you don’t want to see the outlines?