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 闪烁
基础教程推荐
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01