what is the best way?
1) make a method:
Assets.loadAll()
that load all the texture used in the game, and call this method in the splashScreen (so only one time in all the activity life)
OR
2) make one method for each screen (ie. Assets.loadMainMenu, Assets.loadGameScreen, etc..) and call it in the show() of any screen? (and in the hide() call the Assets.disposeMainMenuAssets, Assets.disposeGameScreenAssets, etc etc..)
NOTE: the 2) is slower than the first but in in the first if i block the phone (with classical phisical button) and after go back to the app, the texture disappear (it doesn’t happen if i press the ‘home’ button… but if i lock the phone yes…. and the strange thing is that in libGdx 9.6 if i lock the phone the textures don’t disappear, but with libGdx 9.7 this append..)
If it’s 5MB’s of assets I say just load them on the splash screen. That way there will be little to no “load” time between screen switching. Method 1 is the best for this.
Create a class called
Assets. In this have a static method called “load”, like sopublic class Assets {
(This is just an example from my game. The names aren’t important, just the methods)
On your splash screen you can just call
Assets.load();and all your assets will be loaded!Then you want to use an asset you can just make a call to it via
Assets.whatever(which being static is fine)Hope this helps!