Question

What is the best way to get around the max texture size in Libgdx? I currently have a 2048x2048 texture with an ortho cam zoomed in at 2x which serves as the "map" for my top down shooter. The problem is that 2048x2048 just isn't enough space for the player to move around in, so I need to expand the map without creating a huge texture. Am I going about this wrong? should I not just use a giant texture for the background?

Was it helpful?

Solution

Only some phones will support textures bigger than 2048x2048. This is a GPU hardware/OpenGL driver limitation and not the fault of LibGDX.

The most common solution is to build a map out of several smaller textures that can be repeated to create the illusion of a giant map. You don't just take the map of the world and divide it into 2048x2048 chunks, you instead have a bunch of tiles that are 32x32 pixels and represent things like grass, dirt, grass meeting dirt, etc.

This is why LibGDX has a maps package. See https://github.com/libgdx/libgdx/wiki/Tile-maps

Instead of trying to create the map programmatically you record the map in a text file and use a map loader at runtime. There are a couple of supported map formats. The best way to create the map files is to use a map editor like http://www.mapeditor.org/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top