1
저는 지금 시체를 세계에 렌더링하기 위해 일시적으로 box2ddebugrenderer를 사용하고 있지만, 실행시 전 세계에서 생성되는 몸체의 단색 윤곽선을 볼 수는 없습니다. Box2DdebugRenderer의 바디 윤곽선을 볼 수 없습니다.
이
내 게임 화면의 코드입니다 :public class GameScreen implements Screen {
static final int VIEWPORT_WIDTH = 20;
static final int VIEWPORT_HEIGHT = 13;
World world;
Body ground;
final float TIME_STEP = 1/300f;
float accumulator = 0f;
OrthographicCamera camera;
private Box2DDebugRenderer renderer;
@Override
public void render(float delta) {
//Clear the screen
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.render(world, camera.combined);
accumulator += delta;
while (accumulator >= delta) {
world.step(TIME_STEP, 6, 2);
accumulator -= TIME_STEP;
}
}
@Override
public void show() {
world = createWorld();
ground = createGround(world);
renderer = new Box2DDebugRenderer();
camera = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
camera.position.set(camera.viewportWidth/2, camera.viewportHeight/2, 0f);
camera.update();
}
public World createWorld() {
return new World(Constants.WORLD_GRAVITY, true);
}
public Body createGround(World world) {
BodyDef bodyDef = new BodyDef();
bodyDef.position.set(new Vector2(Constants.GROUND_X, Constants.GROUND_Y));
Body body = world.createBody(bodyDef);
PolygonShape shape = new PolygonShape();
shape.setAsBox(Constants.GROUND_WIDTH/2, Constants.GROUND_HEIGHT/2);
body.createFixture(shape, Constants.GROUND_DENSITY);
shape.dispose();
return body;
}
}