GetHeight() 공개 메소드

Queries how much space this menu entry requires.
public GetHeight ( MenuScreen screen ) : int
screen MenuScreen
리턴 int
예제 #1
0
        /// <summary>
        /// Allows the screen to create the hit bounds for a particular menu entry.
        /// </summary>
        protected virtual Rectangle GetMenuEntryHitBounds(MenuEntry entry)
        {
#if IPHONE
            int scale = 1;
            if (ScreenManager.FixScaleIPhone)
            {
                scale = (int)UIKit.UIScreen.MainScreen.Scale;
            }
#else
            const int scale = 1;
#endif
            // the hit bounds are the entire width of the screen, and the height of the entry
            // with some additional padding above and below.
            if (Portrait)
            {
                return(new Rectangle(
                           0,
                           (int)entry.Position.Y - MenuEntryPadding * scale,
                           ScreenManager.Graphics.PreferredBackBufferHeight,
                           entry.GetHeight(this) + (MenuEntryPadding * 2 * scale)));
            }
            return(new Rectangle(
                       0,
                       (int)entry.Position.Y - MenuEntryPadding * scale,
                       ScreenManager.Graphics.PreferredBackBufferWidth,
                       entry.GetHeight(this) + (MenuEntryPadding * 2 * scale)));
        }
예제 #2
0
파일: MenuScreen.cs 프로젝트: nXqd/XNAGame
        /// <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);

            // 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;

                if (ScreenState == ScreenState.TransitionOn)
                {
                    position.X -= transitionOffset * 256;
                }
                else
                {
                    position.X += transitionOffset * 512;
                }

                // set the entry's position
                menuEntry.Position = position;

                // move down for the next entry the size of this entry
                position.Y += menuEntry.GetHeight(this);
            }
        }
예제 #3
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, (ScreenManager.Game.GraphicsDevice.Viewport.Height / 2) + 12f);

            // 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 = -(400f - ((i * 40f))) + (420f * TransitionAlpha);
                if (position.X > 20f)
                {
                    position.X = 20f;
                }
                //menuEntry.Zoom = 1f;

                //if (ScreenState == ScreenState.TransitionOn)
                //    menuEntry.Zoom += transitionOffset * 10f;
                //else
                //    menuEntry.Zoom = 1f - transitionOffset;

                // set the entry's position
                menuEntry.Position = position;

                // move down for the next entry the size of this entry plus our padding
                position.Y += menuEntry.GetHeight(this) + (menuEntryPadding);
            }
        }
예제 #4
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(
                0,
                (int)entry.Position.Y - menuEntryPadding,
                ScreenManager.GraphicsDevice.Viewport.Width,
                entry.GetHeight(this) + (menuEntryPadding * 2)));
 }
예제 #5
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(
         0,
         (int)entry.Position.Y - menuEntryPadding,
         ScreenManager.GraphicsDevice.Viewport.Width,
         entry.GetHeight(this) + (menuEntryPadding * 2));
 }
예제 #6
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont  font        = ScreenManager.Font;

            Vector2 position = new Vector2(100, 150);

            // 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);

            if (ScreenState == ScreenState.TransitionOn)
            {
                position.X -= transitionOffset * 256;
            }
            else
            {
                position.X += transitionOffset * 512;
            }

            spriteBatch.Begin();

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

                bool isSelected = IsActive && (i == selectedEntry);

                menuEntry.Draw(this, position, isSelected, gameTime);

                position.Y += menuEntry.GetHeight(this);
            }

            // Draw the menu title.
            Vector2 titlePosition = new Vector2(640 / 2, 80);
            Vector2 titleOrigin   = font.MeasureString(menuTitle) / 2;
            Color   titleColor    = new Color(192, 192, 192, TransitionAlpha);
            float   titleScale    = 1.25f;

            titlePosition.Y -= transitionOffset * 100;

            spriteBatch.DrawString(font, menuTitle, titlePosition, titleColor, 0,
                                   titleOrigin, titleScale, SpriteEffects.None, 0);


            spriteBatch.End();
        }
예제 #7
0
 protected override Rectangle GetMenuEntryHitBounds(MenuEntry entry)
 {
     return(new Rectangle((int)entry.Position.X, (int)entry.Position.Y,
                          entry.GetWidth(this), entry.GetHeight(this)));
 }
예제 #8
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // make sure our entries are in the right place before we draw them
            UpdateMenuEntryLocations();

            GraphicsDevice graphics    = ScreenManager.GraphicsDevice;
            SpriteBatch    spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont     font        = styleFont;

            spriteBatch.Begin();

            // Draw each menu entry in turn
            Vector2 firstEntryPosition = Vector2.Zero;
            int     width  = graphics.Viewport.Width / 3;
            int     offset = (int)(graphics.Viewport.Width * 0.025f);

            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

                bool isSelected = IsActive && (i == selectedEntry);

                int height = (int)menuEntry.GetHeight(this);
                rect.X     = (int)menuEntry.Position.X - offset;
                rect.Y     = (int)menuEntry.Position.Y - height / 2;
                rect.Width = width + ((ActivePlayer.FullHDEnabled) ? 0 :
                                      (int)(ScreenManager.GraphicsDevice.Viewport.Width * 0.025f));
                rect.Height = height;

                if (isSelected)
                {
                    spriteBatch.Draw(selectedBackground, rect,
                                     Color.White * (TransitionAlpha - 0.2f));
                }
                else
                {
                    spriteBatch.Draw(menuBackground, rect,
                                     Color.White * (TransitionAlpha - 0.2f));
                }

                menuEntry.Draw(this, isSelected, gameTime);

                if (i == 0)
                {
                    firstEntryPosition = menuEntry.Position;
                }
            }

            // 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);

            // Draw the menu title centered on the screen
            float   titleScale    = 1.25f;
            Vector2 titleSize     = font.MeasureString(menuTitle) * titleScale;
            Vector2 titlePosition = new Vector2(rect.X + ((width - titleSize.X) / 2),
                                                firstEntryPosition.Y - (titleSize.Y * 1.5f));

            titlePosition.Y -= transitionOffset * 100;
            Vector2 titlePosition2 = titlePosition + new Vector2(graphics.Viewport.Width * 0.0025f,
                                                                 graphics.Viewport.Height * 0.0025f);

            // Print menu title
            spriteBatch.DrawString(font, menuTitle, titlePosition, Color.White * TransitionAlpha,
                                   0.0f, Vector2.Zero,
                                   titleScale, SpriteEffects.None, 0.0f);


            spriteBatch.End();

            base.Draw(gameTime);
        }