/// <summary> /// Adds a new screen to the screen manager. /// </summary> public void AddScreen(GameScreen screen) { screen.ScreenManager = this; screen.IsExiting = false; // If we have a graphics device, tell the screen to load content. if (isInitialized) { screen.LoadContent(); } screens.Add(screen); }
/// <summary> /// Removes a screen from the screen manager. You should normally /// use GameScreen.ExitScreen instead of calling this directly, so /// the screen can gradually transition off rather than just being /// instantly removed. /// </summary> public void RemoveScreen(GameScreen screen) { // If we have a graphics device, tell the screen to unload content. if (isInitialized) { screen.UnloadContent(); } screens.Remove(screen); screensToUpdate.Remove(screen); }
/// <summary> /// Draws the button /// </summary> /// <param name="screen">The screen drawing the button</param> public void Draw(GameScreen screen) { // Grab some common items from the ScreenManager SpriteBatch spriteBatch = screen.ScreenManager.SpriteBatch; //SpriteFont font = screen.ScreenManager.Font; SpriteFont font = LoadingScreen.cont.Load<SpriteFont>("dobarFontJe"); Texture2D blank= screen.ScreenManager.BlankTexture; // Compute the button's rectangle Rectangle r = new Rectangle( (int)Position.X + 15, (int)Position.Y, (int)Size.X, (int)Size.Y); // Fill the button //spriteBatch.Draw(blank, r, FillColor * Alpha); Texture2D texture = LoadingScreen.cont.Load<Texture2D>(Path); spriteBatch.Draw(texture,r, Color.White); // Draw the text centered in the button Vector2 textSize = font.MeasureString(Text); Vector2 textPosition = new Vector2(r.Center.X, r.Center.Y); textPosition.X = (int)textPosition.X - 110; textPosition.Y = (int)textPosition.Y; //spriteBatch.DrawString(font, Text, textPosition, TextColor * Alpha); spriteBatch.DrawString(font, Text, textPosition, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); }