0

I write simple game with libGdx. I have a hero, which always is in screen center and I must move my background sprite (or region?) to make move illusion. But my background sprite isn't infinity.

  • How can I create illusion of seamless infinity world?

Of course I can add several background sprites to try to cover all empty space of screen. But I must to draw out of the sceen a lot of all another objects: Houses, monsters, others heroes, etc. So I have a second question:

  • When I try to draw other object (a lot of objects!) out of the screen, how badly it affects memory? How to draw it correctly?

I know that OrthographicCamera in libgdx draw only viewportWidth-viewportHeight area. If it's right, then I must to move my camera and all my sprites too. I think it's not correctly.

  • How can I render infinity world in libgdx with OrthographicCamera?

enter image description here

4

1 回答 1

2

如何创造无缝无限世界的幻觉?

创建平铺背景。平铺背景意味着如果它在自身之外或顶部或底部,则观察者将看不到粘贴线的边缘。
为此,请在 Photoshop 中打开您的背景图像,然后转到“滤镜”>“其他”>“偏移”。设置偏移滤镜以将背景偏移到中心,然后尝试使用 Photoshop 工具隐藏边缘(图像中的 + 形状)。现在再次转到偏移并返回到 0、0 并保存背景。

当我尝试从屏幕上绘制其他对象(很多对象!)时,它对内存的影响有多严重?如何正确绘制?

我已经检查过了,在我的测试中并没有多少 fps 丢失。所以不用担心。

如何使用 OrthographicCamera 在 libgdx 中渲染无限世界?

将相机移动到任何你想要任何 x、y 的地方。每次查看相机在哪里并计算需要绘制的平铺背景(例如每次绘制 3x3=9 个粘在一起的背景)。

于 2013-04-14T09:20:10.577 回答