我正在尝试学习libGdx。但是,我遇到了一个非常非常奇怪的问题。经过一番谷歌搜索后,我开始认为我是唯一一个。基本上,每当我运行应用程序时,它都会开始快速将随机图像闪烁到屏幕上
这是一个例子:
奇怪的是,当渲染方法什么都不做时,它也会这样做。我尝试从中移除所有代码并仍然获得相同的输出。
以下是render方法中发生的事情:
batch.setProjectionMatrix(camera.combined);
batch.begin();
font.draw(batch, "playing", 100, 100);
//The line that I used to test if the code is called
System.out.println("OUTPUT");
batch.end();
另一件奇怪的事情是Gdx.graphics.getDeltaTime()总是为我返回0。
答案 0 :(得分:2)
好的,我通过将这两行添加到渲染方法
来解决了这个问题Gdx.gl.glClearColor(0, 0, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);