3
\$\begingroup\$

Got a really typical use-case here. I have large map made up of hexagons and at any given time only a small section of the map is visible. To provide an overview of the complete map, I want to show a small 2D representation of the map in a corner of the screen.

What is the recommended approach for this in libgdx? Keep in mind the minimap must be updated when the currently visible section changes and when the map is updated.

I've found SpriteBatch(info here), but the warning label on it made me think twice:

A SpriteBatch is a pretty heavy object so you should only ever have one in your program.

I'm not sure I'm supposed to use the one SpriteBatch that I can have on the minimap, and I'm also not sure how to interpret "heavy" in this context.

Another thing to possibly keep in mind is that the minimap will probably be part of a larger UI, is there any way to integrate these two?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

Generate the minimap from your primary map data beforehand. As the player explores, copy the pre-generated minimap data onto the 'known area' minimap texture (or, alternatively, erase the blackness from a mask). You simply pan/rotate/crop this texture as needed.

Generating the entire map on the fly tile by tile TWICE (once for your main map, once for your minimap) is excessive. The minimap is so small you rarely need to worry about texture size or memory limitations, so compression-by-tiling is not a necessary task.

\$\endgroup\$
3
\$\begingroup\$

SpriteBatch allocate Mesh for batching purposes. You can set the size of this Mesh buffer with constructor parameter. Its also create some matrices and couple primitives. Nothing too heavy but warning is just there that people understand that its allocate native resources and its not something that you create every frame.(belive me that is quite often a problem with new comers) It's also create a shader if gles2.0 is used.

Some information related you game and skills would be needed to good answer.

Do you know opengl? Do you use shaders? Do you use fbo's How big portion of screen minimap is covering? is

\$\endgroup\$
1
  • \$\begingroup\$ I'm an experienced programmer, but relatively new to opengl/3d programming. So far i understood almost everything you said ...What's an FBO? :) \$\endgroup\$
    – Bubblewrap
    Commented Apr 11, 2012 at 6:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .