if (!isResuming) { background = Load<Texture2D>(@"Textures\Backgrounds\Instructions"); } else { background = Load<Texture2D>(@"Textures\Backgrounds\Resuming"); } font = Load<SpriteFont>(@"Fonts\MenuFont"); // Create a new instance of the gameplay screen gameplayScreen = new GameplayScreen(levelNumber, movesPerformed); gameplayScreen.ScreenManager = ScreenManager; } Override the method as shown in the following code: “HandleInput” C# public override void HandleInput(InputState input) { if (!isLoading) { if (input.Gestures.Count > 0) { if (input.Gestures[0].GestureType == GestureType.Tap) { // Start loading the resources in an additional thread thread = new Thread( new ThreadStart(gameplayScreen.LoadAssets)); isLoading = true; thread.Start(); } } } base.HandleInput(input); } The preceding method for a tap from the user in order to dismiss the instructions screen. We would like to display the gameplay screen next, but waiting for it to load its assets will cause a noticeable delay between the tap and the appearance of the gameplay screen. Therefore, we will create an additional thread to perform the gameplay screen’s asset initialization. We will display a loading prompt until the process finishes and then display the gameplay screen. Let us move on to the Update method where we will wait for all assets to load. Override the method with the following code: “Update” C# public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
if (!isResuming) { background = Load<Texture2D>(@"Textures\Backgrounds\Instructions"); } else { background = Load<Texture2D>(@"Textures\Backgrounds\Resuming"); } font = Load<SpriteFont>(@"Fonts\MenuFont"); // Create a new instance of the gameplay screen gameplayScreen = new GameplayScreen(levelNumber, movesPerformed); gameplayScreen.ScreenManager = ScreenManager; } Override the “HandleInput” method as shown in the following code: C# public override void HandleInput(InputState input) { if (!isLoading) { if (input.Gestures.Count > 0) { if (input.Gestures[0].GestureType == GestureType.Tap) { // Start loading the resources in an additional thread thread = new Thread( new ThreadStart(gameplayScreen.LoadAssets)); isLoading = true; thread.Start(); } } } base.HandleInput(input); } The preceding method for a tap from the user in order to dismiss the instructions screen. We would like to display the gameplay screen next, but waiting for it to load its assets will cause a noticeable delay between the tap and the appearance of the gameplay screen. Therefore, we will create an additional thread to perform the gameplay screen’s asset initialization. We will display a loading prompt until the process finishes and then display the gameplay screen. Let us move on to the Update method where we will wait for all assets to load. Override the “Update” method with the following code: C# public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
MultitouchGameDevelopmentWithXNA.docx