C# public BackgroundScreen(bool animateDoors) { TransitionOnTime = TimeSpan.FromSeconds(0.0); TransitionOffTime = TimeSpan.FromSeconds(0.5); this.animateDoors = animateDoors; if (animateDoors) { AudioManager.PlaySound("doorOpen"); } } The preceding code simply sets values to some of the properties derived from GameScreen, control how the screen is brought in and out of view and defines if the screen should animate the background. Override the base method to load the background image: “LoadContent” C# public override void LoadContent() { background = Load<Texture2D>(@"Textures\Backgrounds\titleBG"); leftDoor = Load<Texture2D>(@"Textures\Backgrounds\leftDoor"); rightDoor = Load<Texture2D>(@"Textures\Backgrounds\rightDoor"); // Prepare to run the doors’ animation if (animateDoors) doorsInTranistion = true; // Set the doors’ start position leftDoorPosition = Settings.LeftDoorClosedPosition; rightDoorPosition = Settings.RightDoorClosedPosition; } Add custom update logic to the class by overriding the Update method: C# public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { if (doorsInTranistion && animateDoors) AnimateDoors(); base.Update(gameTime, otherScreenHasFocus, false); } This method uses helper method named The helper method produces a sliding “AnimateDoors”. doors animation effect. Add the helper method according to the following code snippet:
C# public BackgroundScreen(bool animateDoors) { TransitionOnTime = TimeSpan.FromSeconds(0.0); TransitionOffTime = TimeSpan.FromSeconds(0.5); this.animateDoors = animateDoors; if (animateDoors) { AudioManager.PlaySound("doorOpen"); } } The preceding code simply sets values to some of the properties derived from GameScreen, control how the screen is brought in and out of view and defines if the screen should animate the background. Override the base “LoadContent” method to load the background image: C# public override void LoadContent() { background = Load<Texture2D>(@"Textures\Backgrounds\titleBG"); leftDoor = Load<Texture2D>(@"Textures\Backgrounds\leftDoor"); rightDoor = Load<Texture2D>(@"Textures\Backgrounds\rightDoor"); // Prepare to run the doors’ animation if (animateDoors) doorsInTranistion = true; // Set the doors’ start position leftDoorPosition = Settings.LeftDoorClosedPosition; rightDoorPosition = Settings.RightDoorClosedPosition; } Add custom update logic to the class by overriding the Update method: C# public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { if (doorsInTranistion && animateDoors) AnimateDoors(); base.Update(gameTime, otherScreenHasFocus, false); } This method uses helper method named “AnimateDoors”. The helper method produces a sliding doors animation effect. Add the helper method according to the following code snippet:
MultitouchGameDevelopmentWithXNA.docx