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);
}
}