Libgdx - how are screens rotated in one viewport?
I created a game in Libgdx that uses a single FitViewport passed to some screens (Splash / Intro / Game / Menu / Pause, etc.).
Each screen has its own scene containing groups of actors. I wrote my own render loop so that screens can fade in / out or slide or show behind each other - all great.
Now I need a "UI" screen that will rotate on smartphones according to their orientation (everything else in the game will NOT rotate).
I can make this work visually using TransformMatrix in SpriteBatch, but this does not affect scene detection (or debugdraw) and there seems to be no way to do this within Stage (localtoparentcoords allows rotation and scale, but NOT transformation)
Keep in mind that it won't be "square" (FitViewport provides a 16x9 ratio), so it needs translation as well as rotation ...
Note. I tried to merge with cameras, but the wrong paradigm is different views of the same thing - I want different things (transform and rotate) to go into the same view!
Please note, I've already started building my own version of the Screen / Stage class for this - I think it might be faster than using existing code to work properly, but I would be surprised if I'm the first person wanting this?
I think I solved this by stepping back a bit and looking at how the Stage / Actor system works.
The idea of rotating and transforming an entire scene is fraught with complexity - I could do it at the SpriteBatch level - it's a distraction that led to a lot of wasted time - unfortunately.
It was only when I realized that by calculating the position of all the elements of my user interface (Actor) in relation to the center of the screen or corner, I can also take the further step of rotating and transforming them at the same time! I also realized that grouping them made it really easy (really, I could have static and rotating elements just by using two separate groups!)
The rotation / movement of the actor will of course also adjust its bounding box / touch area - so now I have a suitable Stage / Group / Actor model that rotates as the device rotates - I could just be static information (scores) or even dynamic menu or overlay for "cue" in pool game or whatever ...
As Edison would say - I didn't spend 2 days, I just spent 2 days finding a lot of ideas that I now know not to work!