【发布时间】:2013-07-25 03:16:20
【问题描述】:
我正在尝试使用 libgdx 绘制一些线进行调试,但我失败了。这是我的代码
public class MainMenu extends Screen implements InputProcessor {
private OrthographicCamera camera;
SpriteBatch myBatch;
ShapeRenderer shapeDebugger;
public MainMenu(Game game) {
super(game);
camera= new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.update();}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
myBatch.begin();
stage.draw();
Gdx.gl10.glLineWidth(10);
shapeDebugger.setProjectionMatrix(camera.combined);
shapeDebugger.begin(ShapeType.Line);
shapeDebugger.setColor(1, 1, 1, 1);
shapeDebugger.line(2, 2, 5, 5);
myBatch.end();
}
}
我收到一条错误消息
shapeDebugger.setProjectionMatrix(camera.combined);
@Pranav008
非常感谢。我没想到我需要启动它。但我有一个真正的问题。我像这样将线画到游戏屏幕的中心。
Gdx.gl10.glLineWidth(2);
shapeDebugger.setProjectionMatrix(camera.combined);
shapeDebugger.begin(ShapeType.Line);
shapeDebugger.setColor(1, 1, 1, 1);
shapeDebugger.line(Gdx.graphics.getWidth()/2, 0,Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight());
shapeDebugger.end();
当我尝试调整屏幕大小时,它不会更新到中心,它会远离右边。
【问题讨论】:
-
你遇到了什么错误?是运行时还是编译时?
标签: libgdx