I'm making a game in LibGDX and I have a couple of menu screens using the scene2d ui. I have one MenuBaseScreen super class that sets up the default actors required for each screen. Then i have a MainMenu, Options etc screens that each inherit from MenuBaseScreen. In each of the screens there is a parallax background that keeps going from right to left. This parallax background gets instantiated in the MenuBaseScreen.
Now the problem with this is that each time I switch screen there is a quick lag because the background have to get re-instantiated and added to the stage again since each subclass calls the super constructor where all of this happens.
So I was wondering if there is a way to persist this image and its animation while switching screens?
Of course I could just replace all the actors except my background and just have one screen instead of many. But I think that approach is kind of clunky and makes for error prone code.
Thank you.
See Question&Answers more detail:os