当前位置: 首页>>代码示例>>C#>>正文


C# SpriteBatch.FadeBackBufferToBlack方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.FadeBackBufferToBlack方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.FadeBackBufferToBlack方法的具体用法?C# SpriteBatch.FadeBackBufferToBlack怎么用?C# SpriteBatch.FadeBackBufferToBlack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.FadeBackBufferToBlack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.GraphicsDevice.Clear(ClearOptions.Target, Color.White, 0, 0);

              spriteBatch.Begin();

              // Draw the background.
              spriteBatch.Draw(editableLevel.Background, Vector2.Zero, Color.White);
              // Draw the walls.
              DrawWalls(spriteBatch);
              // Draw all the level objects.
              DrawLevelObjects(spriteBatch);
              // Draw any informational text.
              DrawText(spriteBatch);

              spriteBatch.End();

              // If the game is transitioning on or off, fade it out to black.
              if (TransitionPosition > 0 || pauseAlpha > 0) {
            float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

            spriteBatch.FadeBackBufferToBlack(alpha);
              }
        }
开发者ID:comp380team3,项目名称:PuzzlePathDimension,代码行数:27,代码来源:GameEditorScreen.cs

示例2: Draw

        /// <summary>
        /// Draws the message box.
        /// </summary>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Darken down any other screens that were drawn beneath the popup.
              spriteBatch.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

              // Center the message text in the viewport.
              Viewport viewport = spriteBatch.GraphicsDevice.Viewport;
              Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height);
              Vector2 textSize = _font.MeasureString(_message);
              Vector2 textPosition = new Vector2(((viewportSize - textSize) / 2).X, 40);

              Rectangle backgroundRectangle = new Rectangle(20, 20, Simulation.FieldWidth - 40,
                                                    Simulation.FieldHeight - 40);

              // Fade the popup alpha during transitions.
              Color color = Color.White * TransitionAlpha;

              spriteBatch.Begin();

              // Draw the background rectangle.
              spriteBatch.Draw(_gradientTexture, backgroundRectangle, color);

              // Draw the platforms in the toolbox, referring to the dictionaries to determine
              // what textures to draw.
              foreach (Rectangle rect in _platforms) {
            Texture2D textureToUse = platformTextures[new Vector2(rect.Width, rect.Height)];
            spriteBatch.Draw(textureToUse, new Vector2(rect.X, rect.Y), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
              }
              foreach (Rectangle rect in _breakablePlatforms) {
            Texture2D textureToUse = breakablePlatformTextures[new Vector2(rect.Width, rect.Height)];
            spriteBatch.Draw(textureToUse, new Vector2(rect.X, rect.Y), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

              }

              if (editableLevel.Custom) {
            deathTrap.Draw(spriteBatch);
            treasure.Draw(spriteBatch);
              }

              // Draw the message box text.
              spriteBatch.DrawString(_font, _message, textPosition, color);

              spriteBatch.End();
        }
开发者ID:comp380team3,项目名称:PuzzlePathDimension,代码行数:47,代码来源:ToolboxScreen.cs

示例3: Draw

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime, SpriteFont font, float transitionAlpha,
            Color color, Texture2D gradientTexture)
        {
            float transitionOffset = (float)Math.Pow(TransitionPosition, 2);
              Vector2 origin = new Vector2(spriteBatch.GraphicsDevice.Viewport.Width / 2, 0);

              // Darken down any other screens that were drawn beneath the popup.
              spriteBatch.FadeBackBufferToBlack(transitionAlpha * 2 / 3);

              GraphicsCursor cursor = new GraphicsCursor();
              cursor.Position = origin;

              spriteBatch.Begin();

              Rectangle backgroundRectangle = new Rectangle(RectangleXPosition, RectangleYPosition,
                                                    ReactangleWidth, RectangleHeight);

              // Draw the background rectangle.
              spriteBatch.Draw(gradientTexture, backgroundRectangle, color);

              // Draw the title
              cursor.Y = backgroundRectangle.Top + font.LineSpacing;

              if (Title != null) {
            GraphicsCursor titleCursor = cursor;

            //Shift the title based on the current transition state.
            titleCursor = (new OffsetEffect(0, -transitionOffset * 100)).ApplyTo(titleCursor);

            Title.Draw(spriteBatch, titleCursor, gameTime);
              }

              //Draw the content
              cursor.Y = 175.0f;
              {
            GraphicsCursor lineCursor = cursor;

            // Modify the alpha to fade text out during transitions.
            lineCursor = (new AlphaEffect(1.0f - TransitionPosition)).ApplyTo(lineCursor);

            // Shift the text based on the current transition state.
            lineCursor = (new OffsetEffect(-transitionOffset * 256, 0)).ApplyTo(lineCursor);

            foreach (IMenuLine line in Lines)
              lineCursor.Y += line.Draw(spriteBatch, lineCursor, gameTime);
              }

              // Draw the buttons
              var labels = new Selection[] { Selection.Left, Selection.Middle, Selection.Right };

              ItemRects.Clear();

              cursor.X = backgroundRectangle.X + 100;
              cursor.Y = backgroundRectangle.Bottom - font.LineSpacing; // This was changed - Jorenz

              foreach (Selection label in labels) {
            MenuButton button;
            Buttons.TryGetValue(label, out button);

               if (button != null) {
              GraphicsCursor buttonCursor = cursor;

              // Modify the alpha to fade text out during transitions.
              buttonCursor = (new AlphaEffect(1.0f - TransitionPosition)).ApplyTo(buttonCursor);

              Rectangle box = button.Draw(spriteBatch, buttonCursor, label == SelectedItem, gameTime);

              ItemRects.Add(Tuple.Create(box, button));
            }

            cursor.X += backgroundRectangle.Width / 3;
              }

              spriteBatch.End();
        }
开发者ID:comp380team3,项目名称:PuzzlePathDimension,代码行数:75,代码来源:MessageBoxTemplate.cs


注:本文中的Microsoft.Xna.Framework.Graphics.SpriteBatch.FadeBackBufferToBlack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。