Libgdx光没有box2d [英] Libgdx light without box2d

查看:163
本文介绍了Libgdx光没有box2d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用libgdx创建游戏。这是一个使用scene2d ui的自上而下的2D射击游戏。现在我想,我可以在一定程度上添加黑暗和光明,但我不想用box2d重写所有内容。我不需要真实的阴影只是某种环境光和我的角色周围的光环,它不受墙壁和其他障碍物的影响。所以我想知道libgdx中是否有任何一种灯光系统?或者我可以使用box2dlights而不使用box2d body / world ......?谢谢

I just started creating a game using libgdx. It is a top down 2d shooter using scene2d ui. Now i thought, that i could add darkness and light to some levels, but i don't want to rewrite everything using box2d. I don't need realistic shadows just some kind of ambient light and a lightcircle arround my character, which is not affected by walls and other obstacles arround him. So i wanted to know if there is any kind of lightsystem in libgdx? Or can i use box2dlights without using box2d bodies/world...? Thanks

推荐答案

不幸的是,LibGDX已经提供了这样的内容。

Unfortunately there is nothing like this already provided by LibGDX.

但如果你不想要阴影,你可以轻松自己做。

But you can easily do it yourself if you do not want shadows.

这里是一个通过LibGDX完成它的人的视频。 这里是文章到这个视频,提供代码和描述以及所有内容。
您可以使用着色器以这种方式执行此操作,但您也可以通过将光照贴图渲染到FBO(在给定的链接中您可以看到如何执行此操作)来执行相同的操作,然后只需使用常规方法渲染它在屏幕顶部激活混合。标准的 SpriteBatch 可以做到这一点,你不需要任何自定义着色器。

Here is a little video of someone who has done it via LibGDX. Here is the article to this video, with code and descriptions and everything provided. You can do it this way with shaders, but you could also do the same by just rendering a lightmap to an FBO (in the given links you can see how to do that) and then just render it the usual way with blending activated on top of your screen. The standard SpriteBatch can do that and you don't need any custom shaders.

如果你还想拥有有障碍的真实阴影,你可能会发现这篇文章很有用。但这要慢得多,需要特殊的着色器。

If you still want to have real shadows with obstacles, you will probably find this article very useful. But this is a lot slower and needs special shaders.

没有Box2dLights也无法使用Box2dLt。

There is also no way to use Box2dLights without Box2D btw.

这篇关于Libgdx光没有box2d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆