Android Question [SOLVED] LibGDX - Interactive tiled map within a stage

Jeffrey Cameron

Well-Known Member
Licensed User
I've looked at the example program that shows you how to create a tiled map and then pinch/zoom/pan which uses the entire display area for the map. What I'd like to know, is how to create that same behavior while containing the map within a portion of the stage rather than occupying the entire stage, something like:
B4X:
+==============================+
|  Main Stage                  |
|  +------------------------+  |
|  |  Tiled map display     |  | 
|  |                        |  |
|  +------------------------+  |
|  [random widget]             |
|  [another widget]            |
|                              |
+==============================+
How can you keep the main stage camera's view fixed and its widgets accessible while changing viewport/zoom on the map? I've tried various combinations of stages and cameras/maprenderers to no avail. This seems like a rather common idea so I hope the answer is a simple one.

Thanks in advance,
- Richard
 

Jeffrey Cameron

Well-Known Member
Licensed User
I've created a demo program that creates a stage, adds group and a text-button and then attempts to render a tiled map inside the group box using its own camera. You can pan as well as zoom the map but its definitely not working as intended.

If someone with more LibGDX knowledge than I posses (which, granted, isn't very much) can look at it and tell me where I went wrong, or how to modify it to constrain the rendered map to just the group box I would be very grateful.

Thanks in advance,

Richard
 

Attachments

Jeffrey Cameron

Well-Known Member
Licensed User
You were spot-on, Informatix, I was attempting to make it too complex. The ClipBegin and ClipEnd methods did the trick!

I've attached the completed example that displays the tiled map within a group and lets you pan/zoom the map within that area. It is fairly heavily documented to explain what is going on.

I've also included a bonus routine that will center the map's camera on the requested table cell and position it in the center of the group viewing area.

Thanks once again for pointing me in the correct direction!
 

Attachments

Top