LibGDX blinking(LibGDX 闪烁)
问题描述
我已经使用 LibGDX UI Setup 来启动一个项目.
I've used the LibGDX UI Setup to start a project.
我在实现 ApplicationListener 中唯一的东西是:
The only thing I have in the implements ApplicationListener is:
public void create() {
setScreen(new LoadingScreen(this));
}
这应该会触发 LoadingScreen 并且确实如此,因为我在它的构造函数中有一个打印并且它确实显示了.我在渲染方法中有一个打印,它只显示一次,我知道这应该打印很多次,因为渲染方法每隔很短的时间就会被调用一次.
This is supposed to fire the LoadingScreen and it does since I have a print in its constructor and it does show. I have a print in the render method and it's only shown once and I understand this should be printed a lot of times since the render method is called every short period of time.
这是我在 render() 方法中的内容(打印除外):
Here's what I have in the render() method (apart from the print):
OpenGL.glClearColor(1, 0.5f, 1, 1);
OpenGL.glClear(GL10.GL_COLOR_BUFFER_BIT);
其中 OpenGL = Gdx.graphics.getGL10();
正如我所说,我认为渲染只被调用一次,当我执行桌面主程序时,我在屏幕上看到的是一个从粉红色到黑色闪烁的图像,以及从上到下的条形.
As I said I think render is only called once and what I see in the screen when I execute the desktop main is an image blinking from pink to black and bars going from top to bottom.
推荐答案
以防万一它对某人有所帮助.
Just in case it It helps someone.
通过在 Game 扩展类中添加 render 方法解决了这个问题:
The problem was solved by adding to the render method in the Game extending class this:
public void render() {
super.render();
}
现在它不会闪烁,并且每个屏幕的渲染都被一遍又一遍地调用,因为它应该发生.
Now it does not blink and each screen's render is called over and over as it is supposed to happen.
这篇关于LibGDX 闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:LibGDX 闪烁


- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 获取数字的最后一位 2022-01-01
- 转换 ldap 日期 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01