Example #1
0
 /// <summary>
 /// Allows the screen to create the hit bounds for a particular menu entry.
 /// </summary>
 protected virtual Rectangle GetMenuEntryHitBounds(MenuEntry entry)
 {
     // the hit bounds are the entire width of the screen, and the height of the entry
     // with some additional padding above and below.
     return(new Rectangle(
                (int)entry.Position.X,
                (int)entry.Position.Y,
                // ScreenManager.GraphicsDevice.Viewport.Width,
                entry.GetWidth(this),
                entry.GetHeight(this)));
 }
Example #2
0
        /// <summary>
        /// Allows the screen the chance to position the menu entries. By default
        /// all menu entries are lined up in a vertical list, centered on the screen.
        /// </summary>
        protected virtual void UpdateMenuEntryLocations()
        {
            // Make the menu slide into place during transitions, using a
            // power curve to make things look more interesting (this makes
            // the movement slow down as it nears the end).
            float transitionOffset = (float)Math.Pow(TransitionPosition, 2);

            // start at Y = 175; each X value is generated per entry
            Vector2 position           = new Vector2(0f, 175f);
            Vector2 positionBackground = new Vector2(0f, 175f);

            // update each menu entry's location in turn
            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

                // each entry is to be centered horizontally
                position.X           = ScreenManager.GraphicsDevice.Viewport.Width / 2 - menuEntry.GetWidth(this) / 2;
                positionBackground.X = ScreenManager.GraphicsDevice.Viewport.Width / 2 - backGround.img.Width / 2;
                if (ScreenState == ScreenState.TransitionOn)
                {
                    position.X           -= transitionOffset * 256;
                    positionBackground.X -= transitionOffset * 256;
                }
                else
                {
                    position.X           += transitionOffset * 512;
                    positionBackground.X += transitionOffset * 512;
                }

                // set the entry's position
                menuEntry.Position = position;
                backGround.rect    = new Rectangle((int)positionBackground.X, 0, backGround.img.Width, ScreenManager.GraphicsDevice.Viewport.Height);

                // move down for the next entry the size of this entry plus our padding
                position.Y += menuEntry.GetHeight(this) + (menuEntryPadding * 2);
            }
        }
Example #3
0
 /// <summary>
 /// Allows the screen to create the hit bounds for a particular menu entry.
 /// </summary>
 protected virtual Rectangle GetMenuEntryHitBounds(MenuEntry entry)
 {
     // the hit bounds are the entire width of the screen, and the height of the entry
     // with some additional padding above and below.
     return new Rectangle(
         (int)entry.Position.X,
         (int)entry.Position.Y,
        // ScreenManager.GraphicsDevice.Viewport.Width,
        entry.GetWidth(this),
         entry.GetHeight(this));
 }