LibGDX 闪烁

LibGDX blinking(LibGDX 闪烁)
本文介绍了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 闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用错误)
Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 语句 - 是“或/“和可能的?)
Java Replace Character At Specific Position Of String?(Java替换字符串特定位置的字符?)
What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作数的三元表达式的类型是什么?)
Read a text file and store every single character occurrence(读取文本文件并存储出现的每个字符)
Why do I need to explicitly cast char primitives on byte and short?(为什么我需要在 byte 和 short 上显式转换 char 原语?)