简体   繁体   English

Java LibGDX Box2D照明bug

[英]Java LibGDX Box2D lighting bug

I have recently started a tile based game. 我最近开始了一个基于平铺的游戏。 So far so good, I implemented Box2D and added rigid bodies for the tiles. 到目前为止,我实施了Box2D并为瓷砖添加了刚体。 Then I added Box2D Lights. 然后我添加了Box2D Lights。 This is where the problem arose. 这就是问题出现的地方。 This is a screenshot of the issue: Image . 这是问题的截图: 图片

As you can see half the screen is rendered, and the other half is not, although the shadows are still created by the bodies. 正如您所看到的那样,一半的屏幕被渲染,而另一半则没有,尽管阴影仍由身体创建。 This is definitely a problem with Box2D lights, because if I disable them the problem disappears. 这绝对是Box2D灯的一个问题,因为如果我禁用它们,问题就会消失。 As far as I can see Box2D lights decides to stop some textures from being rendered, probably because it thinks that they are off screen. 据我所知,Box2D灯决定停止渲染一些纹理,可能是因为它认为它们不在屏幕上。

My Question is, does anyone know what this is or how to solve it? 我的问题是,有谁知道这是什么或如何解决它? I believe that this is a bug, and if anyone knows more help would be appreciated! 我相信这是一个错误,如果有人知道更多的帮助将不胜感激!

My light rendering code is as follows 我的灯光渲染代码如下

// Game stuff is rendered here. This part works fine.

// ...

// Render lights
rayHandler.setCombinedMatrix(PixelEngineers.camera);
rayHandler.updateAndRender();   

Alright, my fault, solved this by rendering the lights AFTER the batch had been ended. 好吧,我的错,通过在批次结束后渲染灯来解决这个问题。 // Game stuff is rendered here. //游戏内容在这里呈现。 This part works fine. 这部分工作正常。

// ... // ...

batch.end() batch.end()

// Render lights rayHandler.setCombinedMatrix(PixelEngineers.camera); //渲染光线rayHandler.setCombinedMatrix(PixelEngineers.camera); rayHandler.updateAndRender(); rayHandler.updateAndRender(); ` `

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM