/// <summary> /// Queries how much space this menu entry requires. /// </summary> public virtual int GetHeight(MenuScreen screen) { return((int)Math.Floor(texture.Height * 0.8f)); }
/// <summary> /// Draws the menu entry. This can be overridden to customize the appearance. /// </summary> public virtual void Draw( MenuScreen screen, Vector2 position, bool isSelected, GameTime gameTime ) { // Pulsate the size of the selected menu entry. double time = gameTime.TotalGameTime.TotalSeconds; float pulsate = (float)Math.Sin( time * 6 ) + 1; float scale = 0.7f + pulsate * 0.05f * selectionFade; // Draw texture, centered on the screen ScreenManager screenManager = screen.ScreenManager; SpriteBatch spriteBatch = screenManager.SpriteBatch; if( texture != null ) { spriteBatch.Draw( texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0 ); } }
/// <summary> /// Queries how much space this menu entry requires. /// </summary> public virtual int GetHeight( MenuScreen screen ) { return (int)Math.Floor( texture.Height * 0.8f ); }
/// <summary> /// Updates the menu entry. /// </summary> public virtual void Update( MenuScreen screen, bool isSelected, GameTime gameTime ) { // When the menu selection changes, entries gradually fade between // their selected and deselected appearance, rather than instantly // popping to the new state. float fadeSpeed = (float)gameTime.ElapsedGameTime.TotalSeconds * 4; if( isSelected ) selectionFade = Math.Min( selectionFade + fadeSpeed, 1 ); else selectionFade = Math.Max( selectionFade - fadeSpeed, 0 ); }