/// <summary> /// The constructor is private: loading screens should /// be activated via the static Load method instead. /// </summary> private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow, GameScreen[] screensToLoad) { this.loadingIsSlow = loadingIsSlow; this.screensToLoad = screensToLoad; TransitionOnTime = TimeSpan.FromSeconds(0.5); }
public Game1() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferHeight = 720; graphics.PreferredBackBufferWidth = 1280; graphics.IsFullScreen = false; screenManager = new ScreenManager(this); Components.Add(screenManager); screenManager.AddScreen(new BackgroundScreen(), null); }
/// <summary> /// Activates the loading screen. /// </summary> public static void Load(ScreenManager screenManager, bool loadingIsSlow, PlayerIndex? controllingPlayer, params GameScreen[] screensToLoad) { // Tell all the current screens to transition off. for (int i = 0; i < screenManager.GetScreens().Length; i++) screenManager.GetScreens()[i].ExitScreen(); // Create and activate the loading screen. LoadingScreen loadingScreen = new LoadingScreen(screenManager, loadingIsSlow, screensToLoad); screenManager.AddScreen(loadingScreen, controllingPlayer); }
/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(GameTime gameTime) { // This game has a red background. Why? Because BLOOD LOL ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Red, 0, 0); currentLevel.Draw(); Game1.getGraphicsDevice().SetRenderTarget(null); // If the game is transitioning on or off, fade it out to black. if (TransitionPosition > 0 || pauseAlpha > 0) { float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2); ScreenManager.FadeBackBufferToBlack(alpha); } if (player.controls.Locked && !oldPlayerLocked) //fade out { //Debug.WriteLine("fade out!"); fadeOut = true; fadeIn = false; iAlpha = 255; } else if (!player.controls.Locked && oldPlayerLocked) //fade in { //Debug.WriteLine("fade in!"); fadeIn = true; fadeOut = false; iAlpha = 0; } else { if (fadeIn) { iAlpha += 1; //Debug.WriteLine("alpha="+iAlpha); if (iAlpha == 255) { fadeIn = false; } //Debug.WriteLine("fadein=" + fadeIn); } if (fadeOut) { iAlpha -= 1; //Debug.WriteLine("alpha=" + iAlpha); if (iAlpha == 0) { fadeOut = false; } //Debug.WriteLine("fadeout=" + fadeOut); } } DrawUI(); oldPlayerLocked = player.controls.Locked; ScreenManager.GraphicsDevice.RasterizerState = RasterizerState.CullNone; ScreenManager.GraphicsDevice.BlendState = BlendState.Opaque; ScreenManager.GraphicsDevice.DepthStencilState = DepthStencilState.Default; ScreenManager.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; }