예제 #1
0
        private void DrawShadowedString(FontFile font, string value, Vector2 position, Color color)
        {
            FontRenderer fontRender = new FontRenderer(fontPrinceOfPersia_small, fontTexturePrinceOfPersia_small);

            fontRender.DrawString(spriteBatch, position, value);

            //fontRender.DrawString(font, value, position + new Vector2(1.0f, 1.0f), Color.Black);
            //spriteBatch.DrawString(font, value, position, color);
        }
예제 #2
0
        /// <summary>
        /// Draws the loading screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // If we are the only active screen, that means all the previous screens
            // must have finished transitioning off. We check for this in the Draw
            // method, rather than in Update, because it isn't enough just for the
            // screens to be gone: in order for the transition to look good we must
            // have actually drawn a frame without them before we perform the load.
            if ((ScreenState == ScreenState.Active) &&
                (ScreenManager.GetScreens().Length == 1))
            {
                otherScreensAreGone = true;
            }

            // The gameplay screen takes a while to load, so we display a loading
            // message while that is going on, but the menus load very quickly, and
            // it would look silly if we flashed this up for just a fraction of a
            // second while returning from the game to the menus. This parameter
            // tells us how long the loading is going to take, so we know whether
            // to bother drawing the message.
            if (loadingIsSlow)
            {
                SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
                SpriteFont  font        = ScreenManager.Font;

                string message     = "LOADING... ";
                string LoaderCount = Program.LoaderCount.ToString() + " %";
                message += LoaderCount;


                // Center the text in the viewport.
                Viewport viewport     = ScreenManager.GraphicsDevice.Viewport;
                Vector2  viewportSize = new Vector2(viewport.Width, viewport.Height);



                Color color = Color.White * TransitionAlpha;

                // Draw the text.
                spriteBatch.Begin();

                FontRenderer fontRender   = new FontRenderer(ScreenManager.FontFile, ScreenManager.FontTexture);
                Vector2      textSize     = fontRender.MeasureString(message);
                Vector2      textPosition = (viewportSize - textSize) / 2;
                fontRender.DrawString(spriteBatch, textPosition, message);


                //spriteBatch.DrawString(font, message, textPosition, color);
                spriteBatch.End();
            }
        }
예제 #3
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public virtual void Draw(MenuScreen 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 = screenManager.Font;

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

            //spriteBatch.DrawString(font, text, position, color, 0, origin, scale, SpriteEffects.None, 0);


            FontRenderer fontRender = new FontRenderer(screenManager.FontFile, screenManager.FontTexture);
            fontRender.DrawString(spriteBatch, position, text);
        }