Best way to load big background in libgdx

浪尽此生 提交于 2019-12-12 14:02:45

问题


I am developing a game using libgdx. Now i'd like to have a Background all over my map (Map size is not fixed yet i'll decide later). My map is tile based but i don't use TiledMaps. So i create and load the map with own code/editor.

My question now: How should i implement the background thing?

I thought about different ways:

  • Loading a huge Image, which covers all the map. This is not realy good cause i render things, which are not in my viewport (80 Tiles X,50 Tiles Y).

  • Deviding the Image in 4 or more Images and loading the one in the viewport. The Problem: At some point maybe part of all Images is in viewport so all Images are sent to GPU right?

  • Having 1 Image which cover the viewport (80,50) and follows the camera. Best performance i think, but it will look stupid...

  • Or every tile has an own Image and the Objects are drawn above them. Notice that i only render Tiles inside the viewport. But on Gamestart it would need to load Information about every tile in the level.

For Information: My Game is Topdown and the Background Shows the floor so no detailed hills etc are needed, just maybe some simple desert sand look and things like that. Is there another even better way?

What would be the best way for performance and optic?


回答1:


If your game is Tile Based. It would make much more sense to have the background tiled aswell. Just use another layer for it. If your editor/loader does not support multiple layers, then I would recommend you to switch to another one, or add those features to it (if possible).

The Background Shows the floor so no detailed hills etc are needed, just maybe some simple desert sand look and things like that.

It is very easy to reuse tiles in something like a desert, because all their tiles are very similar (sand).



来源:https://stackoverflow.com/questions/21164348/best-way-to-load-big-background-in-libgdx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!