问题
So drawing a shape should be really easy, right? Well, the following draws exactly nothing.
...why?
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
shapeRenderer.setProjectionMatrix(camera.combined);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(Color.WHITE);
shapeRenderer.rect(WIDTH / 2, HEIGHT / 2, 50, 50);
shapeRenderer.end();
回答1:
Make sure your camera is properly initialized.
For Example:
camera = new OrthographicCamera(); //Put this in init
camera.setToOrtho(0,0,WIDTH,HEIGHT);
来源:https://stackoverflow.com/questions/24062348/libgdx-shaperenderer-drawing-nothing