IsLoadingScreen
Last updated
Last updated
The IsLoadingScreen property can be used to mark a Screen as a loading screen. Loading screens can be used when transitioning into a Screen which must load a lot of content or when returning back into the app after it goes to sleep (tombstones) on a phone.
To mark a Screen as a loading screen, simply set the IsLoadingScreen property to "True":
For this example we'll assume you have a Screen called LoadingScreen which has its IsLoadingScreen property set to true. To use the LoadingScreen:
Identify which screen transitions you want to use a LoadingScren between. For example, you may want to use the LoadingScreen between a main menu screen and the game screen if the game screen has a lot of content to load.
Locate where you want the transition to occur (like when the user presses the Start button or clicks on a button) and add the following code:
You can manually set the next screen even if you do not have an instance of a LoadingScreen (which is required for the TransitionToScreen method. You can do this by setting the static NextScreen property. This is useful if:
You are using the loading screen as the first screen in your game
You are using the loading screen to display something while your app returns from tombstoning
You want to set the next screen before you have created the loading screen (such as in response to a button push)
The following code shows how to use the LoadingScreen as your first screen. This code belongs in Game1.cs's Initialize method. Note that ScreenManager.Start will automatically get generated by Glue, so you would only add the code to set the LoadingScreen's NextScreen.
The TransitionToScreen method is an easy way to move between two Screens. It will
Unload/destroy the current Screen
Load the LoadingScreen and make it the primary Screen
Begin loading the argument Screen (GameScreen in the example above) in a secondary thread
Performs every-frame activity on the LoadingScreen which can be used to play animations or other activity to give the user an indication that the game is not frozen.
The IsLoadingScreen property can help you create loading screens quickly; however there are some things to consider which can make the user experience better:
Keep the logic in the loading screens simple to reduce the amount of resources spent on running your loading screen.
Keep the amount of content loaded on your Screen low. If this is not possible or desirable, consider making the content that is part of your loading screen also a part of Global Content Files. Your game will pre-load this content if you are using async global content loading.
Consider making your loading screens use a global content manager. This means the loading screen's content (such as used textures and Scenes) will always remain in memory making transitioning to a loading screen very fast.
Be careful using minigames in your loading screen. There is currently a patent held by Namco on the use of minigames in loading screens.