コード例 #1
0
ファイル: LoadingScreen.cs プロジェクト: milesgray/resatiate
        /// <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);
        }
コード例 #2
0
ファイル: MenuEntry.cs プロジェクト: milesgray/resatiate
        public bool Collides(Vector2 point, GameScreen screen)
        {
            this.size = new Vector2
            {
                X = this.GetWidth(screen),
                Y = this.GetHeight(screen)
            };
            var rect = new Rectangle
            {
                X = (int)this.position.X,
                Y = (int)this.position.Y,
                Width = (int)this.size.X,
                Height = (int)this.size.Y
            };

            return rect.Contains(new Point((int)point.X, (int)point.Y));
        }
コード例 #3
0
ファイル: MenuEntry.cs プロジェクト: milesgray/resatiate
 /// <summary>
 /// Constructs a new menu entry with the specified text.
 /// </summary>
 public MenuEntry(string text, GameScreen screen)
 {
     this.text = text;
 }
コード例 #4
0
ファイル: MenuEntry.cs プロジェクト: milesgray/resatiate
 /// <summary>
 /// Queries how wide the entry is, used for centering on the screen.
 /// </summary>
 public virtual int GetWidth(GameScreen screen)
 {
     return (int)screen.ScreenManager.Font.MeasureString(Text).X;
 }
コード例 #5
0
ファイル: MenuEntry.cs プロジェクト: milesgray/resatiate
 /// <summary>
 /// Queries how much space this menu entry requires.
 /// </summary>
 public virtual int GetHeight(GameScreen screen)
 {
     return screen.ScreenManager.Font.LineSpacing;
 }
コード例 #6
0
ファイル: MenuEntry.cs プロジェクト: milesgray/resatiate
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public virtual void Draw(GameScreen screen, bool isSelected, GameTime gameTime)
        {
            // there is no such thing as a selected item on Windows Phone, so we always
            // force isSelected to be false
            #if WINDOWS_PHONE
            isSelected = false;
            #endif

            // Draw the selected entry in yellow, otherwise white.
            Color color = isSelected ? Color.Yellow : Color.White;

            // Pulsate the size of the selected menu entry.
            double time = gameTime.TotalGameTime.TotalSeconds;

            float pulsate = (float)Math.Sin(time * 6) + 1;

            float scale = 1 + pulsate * 0.05f * selectionFade;

            // Modify the alpha to fade text out during transitions.
            color *= screen.TransitionAlpha;

            // Draw text, centered on the middle of each line.
            ScreenManager screenManager = screen.ScreenManager;
            SpriteBatch spriteBatch = screenManager.SpriteBatch;
            SpriteFont font = screen.screenManager.Content.Load<SpriteFont>("systemfont"); ;

            Vector2 origin = new Vector2(0, font.LineSpacing / 2);

            spriteBatch.DrawString(font, text, position, color, 0,
                                   origin, scale, SpriteEffects.None, 0);
        }
コード例 #7
0
ファイル: ScreenManager.cs プロジェクト: milesgray/resatiate
        /// <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);

            // if there is a screen still in the manager, update TouchPanel
            // to respond to gestures that screen is interested in.
            if (screens.Count > 0)
            {
                TouchPanel.EnabledGestures = screens[screens.Count - 1].EnabledGestures;
            }
        }
コード例 #8
0
ファイル: ScreenManager.cs プロジェクト: milesgray/resatiate
        /// <summary>
        /// Adds a new screen to the screen manager.
        /// </summary>
        public void AddScreen(GameScreen screen, PlayerIndex? controllingPlayer)
        {
            screen.ControllingPlayer = controllingPlayer;
            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);

            // update the TouchPanel to respond to gestures this screen is interested in
            TouchPanel.EnabledGestures = screen.EnabledGestures;
        }