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


C# SpriteBatch.End方法代码示例

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


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

示例1: ReflectionRender

 public override void ReflectionRender(SpriteBatch spriteBatch)
 {
     if (this.txTexture == RenderMaster.txNullTex)
     {
         return;
     }
     this.txToUse = this.txTexture;
     if (this.dentxAlternateTextures.ContainsKey(RenderMaster.enCurrentPass))
     {
         this.txToUse = this.dentxAlternateTextures[RenderMaster.enCurrentPass];
     }
     if (base.xEffectWrapper == null)
     {
         spriteBatch.Draw(this.txToUse, Utility.Vector2_ToInts(this.xTransform.v2Pos - this.v2OffsetRenderPos) - Utility.Vector2_ToInts(this.xCamera.v2TopLeft * this.v2ParallaxFactor), null, this.cColor * this.fAlpha, this.fRotation, new Vector2(this.v2Offset.X, (float)this.txTexture.Height - this.v2Offset.Y), this.v2Scale, this.enSpriteEffect | SpriteEffects.FlipVertically, 0f);
         return;
     }
     spriteBatch.End();
     foreach (KeyValuePair<string, float> kvp in this.dsfFloatShaderParameters)
     {
         base.xEffectWrapper.xEffect.Parameters[kvp.Key].SetValue(kvp.Value);
     }
     spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, null, base.xEffectWrapper.xEffect);
     spriteBatch.Draw(this.txToUse, Utility.Vector2_ToInts(this.xTransform.v2Pos - this.v2OffsetRenderPos) - Utility.Vector2_ToInts(this.xCamera.v2TopLeft * this.v2ParallaxFactor), null, this.cColor * this.fAlpha, this.fRotation, new Vector2(this.v2Offset.X, (float)this.txTexture.Height - this.v2Offset.Y), this.v2Scale, this.enSpriteEffect | SpriteEffects.FlipVertically, 0f);
     spriteBatch.End();
     spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, null);
 }
开发者ID:ancientgods,项目名称:SoG,代码行数:26,代码来源:StaticRenderComponent.cs

示例2: Draw

        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

        //TODO: Add your Draw logic here
                spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive);
            EntityManager.Draw(spriteBatch);
            spriteBatch.End();

            spriteBatch.Begin(0, BlendState.Additive);

            spriteBatch.DrawString(Art.Font, "Lives: " + PlayerStatus.Lives, new Vector2(5), Color.White);
            drawRightAlignedString("Score: " + PlayerStatus.Score, 5, Color.White);
            drawRightAlignedString("Multiplier: " + PlayerStatus.Multiplier, 35, Color.White);


            if (PlayerStatus.IsGameOver)
            {
                string text = "Game Over\n" +
                    "Your Score: " + PlayerStatus.Score + "\n" +
                    "High Score: " + PlayerStatus.HighScore;

                drawCentertAlignedString(text, Color.White);
            }

            // draw the custom mouse cursor
            spriteBatch.Draw(Art.Pointer, Input.MousePosition, Color.White);

            spriteBatch.End();
        }
开发者ID:Nianmi,项目名称:SpaceFighter,代码行数:30,代码来源:PlayScreen.cs

示例3: Draw

        public void Draw(SpriteBatch batch)
        {
            if (enabled && render)
            {
                Main.graphics.GraphicsDevice.SetRenderTarget(swapTarget);
                Main.graphics.GraphicsDevice.Clear(Color.Transparent);
                batch.End();
                batch.Begin();
                batch.Draw(visualGridSprites[focus], Main.screenRect, Color.White);

                for (int i = 0; i < width; i++)
                    for (int j = 0; j < height; j++)
                    {
                        if (grid[i, j].inhabitants.Count > 0)
                        {
                            batch.Draw(Main.sprites["filledGrid"], new Rectangle((int)(i * gridSize.X), (int)(j * gridSize.Y), (int)gridSize.X, (int)gridSize.Y), (grid[i, j].inhabitants[0] as IDrawableGridAsset).gridColor);
                        }

                    }
                batch.End();
                batch.Begin();

                Main.graphics.GraphicsDevice.SetRenderTarget(null);
                visualGrid = new DrawableAsset<RenderTarget2D>(new Vector2(Main.windowSize.X / 2, Main.windowSize.Y / 2), new Vector2(0, -1), Main.windowSize, swapTarget);
                visualGrid.Draw(batch);
            }
        }
开发者ID:alexander-jones,项目名称:Kinect-Snake,代码行数:27,代码来源:VisualGrid.cs

示例4: Draw

        public static void Draw(SpriteBatch spriteBatch)
        {
            //gsm.game.GraphicsDevice.SetRenderTarget(overlayTarget);
            //gsm.game.GraphicsDevice.Clear(Color.Transparent);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

            words1.Draw(spriteBatch);
            words2.Draw(spriteBatch);
            words3.Draw(spriteBatch);
            words4.Draw(spriteBatch);
            words5.Draw(spriteBatch);
            words6.Draw(spriteBatch);

            spriteBatch.End();

            if (fadeOverlay.color == Color.Black)
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
            else if (fadeOverlay.color == Color.White)
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive);
            else
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
            fadeOverlay.Draw(spriteBatch);
            spriteBatch.End();

            //gsm.game.GraphicsDevice.SetRenderTarget(null);
            //spriteBatch.Begin();
            //spriteBatch.Draw(overlayTarget, Vector2.Zero, Color.White);
            //spriteBatch.End();
        }
开发者ID:jacobnelson,项目名称:WorldsApart,代码行数:30,代码来源:GSOverlay.cs

示例5: draw

        public override void draw(SpriteBatch spriteBatch)
        {
            Game1.graphics.GraphicsDevice.Clear(Color.Lerp(Color.DarkGray, Color.White, 0.4f));

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, Game1.grayCheckerBoard, Matrix.CreateScale(720, 480, 0));
            spriteBatch.Draw(Game1.globalBlackPixel, Vector2.Zero, Color.White);
            spriteBatch.End();

            spriteBatch.Begin();
            for (int i = 0; i < menuList.Count; i++)
            {
                MBQG.drawGUIBox(spriteBatch, new Vector2((float)(144 + (25 * menuList[i].distanceOut)), 81 + i * 64), 28, 3, (i <= Game1.MagnetBoySaveData.furthestLevelUnlocked) ? Color.Purple : Color.Lerp(Color.Purple, Color.Black, 0.5f), AnimationFactory.DepthLayer3);
                spriteBatch.DrawString(Game1.gameFontText, Game1.levelNames[i], new Vector2((float)(152 + (25 * menuList[i].distanceOut)), 85 + i * 64), Color.Lerp(Color.Black, Color.White, (float)menuList[i].distanceOut));
                if (i <= Game1.MagnetBoySaveData.furthestLevelUnlocked)
                {
                    spriteBatch.DrawString(Game1.gameFontText, "BEST TIME COMPLETED IN " + (Game1.MagnetBoySaveData.levelBestTime(i) / 1000) , new Vector2((float)(168 + (25 * menuList[i].distanceOut)), 106 + i * 64), Color.Lerp(new Color(40, 40, 40), Color.DarkGray, (float)menuList[i].distanceOut));
                }
                else
                {
                    spriteBatch.DrawString(Game1.gameFontText, "LOCKED", new Vector2((float)(168 + (25 * menuList[i].distanceOut)), 106 + i * 64), Color.Lerp(new Color(40, 40, 40), Color.DarkGray, (float)menuList[i].distanceOut));
                }
            }

            AnimationFactory.drawAnimationFrame(spriteBatch, "xboxButtons", 0, new Vector2(220, 400), AnimationFactory.DepthLayer0);
            spriteBatch.DrawString(Game1.gameFontText, "Begin Level", new Vector2(245, 401), Color.Black);

            AnimationFactory.drawAnimationFrame(spriteBatch, "xboxButtons", 3, new Vector2(425, 400), AnimationFactory.DepthLayer0);
            spriteBatch.DrawString(Game1.gameFontText, "Back", new Vector2(450, 401), Color.Black);
            spriteBatch.End();
        }
开发者ID:FrostTree-Games,项目名称:ZippyPushKid,代码行数:30,代码来源:LevelSelectMenuState.cs

示例6: Draw

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(TextureManager.Instance.GetTextureByString("pixel"), _outLine, Color.Azure);
            spriteBatch.Draw(TextureManager.Instance.GetTextureByString("pixel"), _inLine, _bgColor);
            spriteBatch.Draw(TextureManager.Instance.GetTextureByString("pixel"), _scrollUp, Color.FloralWhite);
            spriteBatch.Draw(TextureManager.Instance.GetTextureByString("pixel"), _scrollDown, Color.FloralWhite);
            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, null, null, null, _camera.GetTransformMatrix());
            if (_rowList.Count > 0 && _scrollIndex < _rowList.Count-1)
                for (int i = _rowList[_scrollIndex]; i < _rowList[_scrollIndex + 1]; i++)
                    _spriteList[i].Draw(spriteBatch);

            if (_scrollIndex == _rowList.Count-1)
                for (int i = _rowList[_scrollIndex]; i < _spriteList.Count; i++)
                    _spriteList[i].Draw(spriteBatch);
            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, null, null, null, _camera.GetTransformMatrix());
            if (_selectedSprite != null)
                _selectedSprite.Draw(spriteBatch, Color.Red, 0.5f);
                

            spriteBatch.End();
            base.Draw(spriteBatch);
        }
开发者ID:TheEternalCircle,项目名称:TheEternalCircleMasterSolution,代码行数:27,代码来源:HImageListView.cs

示例7: Render

 public override void Render(SpriteBatch spriteBatch)
 {
     if (this.bRenderShadow)
     {
         if (this.bCustomShadow)
         {
             spriteBatch.Draw(this.txShadowTexture, Utility.Vector2_ToInts(this.xTransform.v2Pos) - this.xCamera.v2TopLeft, null, this.cColor * this.fAlpha, 0f, this.v2Offset, base.fScale, SpriteEffects.None, 0f);
         }
         else
         {
             spriteBatch.Draw(ItemRenderComponent.txGenericShadow, Utility.Vector2_ToInts(this.xTransform.v2Pos) - this.xCamera.v2TopLeft, null, this.cColor * 0.6f, 0f, ItemRenderComponent.v2ShadowOffset, 1f, SpriteEffects.None, 0f);
         }
     }
     if (base.xEffectWrapper == null)
     {
         spriteBatch.Draw(this.txTexture, Utility.Vector2_ToInts(this.xTransform.v2Pos + this.v2OffsetRenderPos) - this.xCamera.v2TopLeft, null, this.cColor * this.fAlpha, this.fRotation, this.v2Offset, base.fScale, SpriteEffects.None, 0f);
         return;
     }
     spriteBatch.End();
     foreach (KeyValuePair<string, float> kvp in this.dsfFloatShaderParameters)
     {
         base.xEffectWrapper.xEffect.Parameters[kvp.Key].SetValue(kvp.Value);
     }
     spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, null, base.xEffectWrapper.xEffect);
     spriteBatch.Draw(this.txTexture, Utility.Vector2_ToInts(this.xTransform.v2Pos + this.v2OffsetRenderPos) - this.xCamera.v2TopLeft, null, this.cColor * this.fAlpha, this.fRotation, this.v2Offset, base.fScale, SpriteEffects.None, 0f);
     spriteBatch.End();
     spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, null);
 }
开发者ID:ancientgods,项目名称:SoG,代码行数:28,代码来源:ItemRenderComponent.cs

示例8: Draw

        public void Draw(SpriteBatch sb)
        {
            sb.Begin();
            sb.Draw(gameOverText, new Rectangle(0, 0, 1920, 1080), Color.White * gameOverOpacity);
            sb.End();

            if (titleButtonPosition != null && titleButtonPosition.Y > 0)
            {
                sb.Begin();
                sb.Draw(buttonTexture, new Rectangle(530, 780, 870, 100), c);
                sb.End();

                sb.Begin();
                sb.Draw(buttonTexture, new Rectangle(525, 775, 870, 100), Color.White);
                sb.End();

                sb.Begin();
                sb.Draw(buttonTexture, new Rectangle(525, 775, 870, 100), c);
                sb.End();

                sb.Begin();
                sb.DrawString(font, "RETURN TO TITLE SCREEN", titleButtonPosition, Color.White);
                sb.End();
            }
        }
开发者ID:Siryu,项目名称:Dinosaur-Laser-Assault,代码行数:25,代码来源:Death.cs

示例9: draw

        public override void draw(SpriteBatch sb)
        {
            if (m_unitHealth > 0)
            {
                sb.Begin();
                sb.Draw(m_baseTexture, m_position, null, Color.White, 0, m_origin, 0.5f, SpriteEffects.None, 0);
                sb.End();

                sb.Begin();

                foreach (Bullet curB in bullets)
                {
                    curB.draw(sb);
                }

                sb.Draw(m_texture, m_position, null, Color.White, m_rotation, m_origin, 0.5f, SpriteEffects.None, 0);

                if (m_displayInfo)
                {
                    drawDisplayInfo(sb);
                }

                sb.End();
            }
        }
开发者ID:CarbonBasedDudeform,项目名称:2D-Zombie-Survival-RTS,代码行数:25,代码来源:SentryGun.cs

示例10: Draw

        public override void Draw(SpriteBatch batch)
        {
            batch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.Transform);

            world.Map.Draw(batch);

            world.BulletManager.Draw(batch);

            world.Player.Draw(batch);

            foreach (var enemy in world.Enemies)
            {
                enemy.Draw(batch);
            }

            foreach (var power in world.Powers)
            {
                power.Draw(batch);
            }

            batch.End();

            batch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, hudCamera.Transform);
            hud.Render(batch);
            batch.End();
        }
开发者ID:ThaH3lper,项目名称:AD_Project,代码行数:26,代码来源:GameScene.cs

示例11: Draw

        public override void Draw(SpriteBatch batch)
        {
            int tilesWide = (int)(currentLayer.LayerTexture.Width / map.TileDimensions.Width);
            int tilesHigh = (int)(currentLayer.LayerTexture.Height / map.TileDimensions.Height);

            batch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);
            batch.Draw (backgroundTexture, new Rectangle (0, 0, Moxy.ScreenWidth, Moxy.ScreenHeight), null, Color.Black);
            batch.End();

            batch.Begin (SpriteSortMode.Texture, BlendState.AlphaBlend);

            for (int x = 0; x < tilesWide; x++)
            {
                for (int y = 0; y < tilesHigh; y++)
                {
                    var tileID = (y * tilesWide) + x;
                    var tileLocation = new Vector2(x * (map.TileDimensions.Width * scale), y * (map.TileDimensions.Height * scale))
                        + tileDisplayOffset;

                    // Draw the tile at it's respective location
                    batch.Draw (currentLayer.LayerTexture, tileLocation, currentLayer.LayerBounds[tileID], Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 1f);

                    // Highlight if it's currently selected
                    if (tileID == mapState.currentTileID)
                        batch.Draw (mapState.highlightTexture, tileLocation, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 1f);
                }
            }

            batch.End();
        }
开发者ID:NullSoldier,项目名称:Moxy,代码行数:30,代码来源:TilePickerOverlay.cs

示例12: draw

        public static void draw(SpriteBatch sb,Texture2D tex1)
        {
            sb.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);
            //shaders.MainMenuBlurBegin();
            sb.Draw(tex1, Vector2.Zero, Color.White);
            //shaders.MainMenuBlurEnd();
            sb.End();

            sb.Begin();
            if (timeWaited < 3)
            {
                if (timeWaited > 0.5f)
                {
                    if (Controller.is_a_pressed(PlayerIndex.One))
                        timeWaited = 3;
                }

                sb.Draw(howtoTex, Vector2.Zero, Color.White);
            }
            else
            {
                if (Controller.is_a_pressed(PlayerIndex.One))
                    timeWaited = 5;
                sb.Draw(controls, Vector2.Zero, Color.White);
            }
            timeWaited += 0.005f;
            if (timeWaited > 5)
            {
                Game1.currentMenu = Game1.activeMenu.main;
                timeWaited = 0;
            }

            sb.End();
        }
开发者ID:mrpossoms,项目名称:AnimoNex,代码行数:34,代码来源:howto.cs

示例13: ConvertToPreMultipliedAlphaGPU

        public static Texture2D ConvertToPreMultipliedAlphaGPU(Texture2D texture)
        {
            // code borrowed from http://jakepoz.com/jake_poznanski__speeding_up_xna.html

            // Set up a render target to hold our final texture which will have premulitplied alpha values
            RenderTarget2D result = new RenderTarget2D(device, texture.Width, texture.Height);

            device.SetRenderTarget(result);
            device.Clear(Color.Black);

            // Multiply each color by the source alpha, and write in just the color values into the final texture
            SpriteBatch spriteBatch = new SpriteBatch(device);
            spriteBatch.Begin(SpriteSortMode.Immediate, blendColor);
            spriteBatch.Draw(texture, texture.Bounds, Color.White);
            spriteBatch.End();

            // Now copy over the alpha values from the PNG source texture to the final one, without multiplying them
            spriteBatch.Begin(SpriteSortMode.Immediate, blendAlpha);
            spriteBatch.Draw(texture, texture.Bounds, Color.White);
            spriteBatch.End();

            // Release the GPU back to drawing to the screen
            device.SetRenderTarget(null);

            return result as Texture2D;
        }
开发者ID:zetaPRIME,项目名称:xybrid,代码行数:26,代码来源:GraphicsManager.cs

示例14: Draw

        public override void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch)
        {
            if (!end)
            {
                spriteBatch.Begin();
                StringTool.DrawString(spriteBatch, DataSystem.fontCourierNew, "White: " + white.HP.ToString(), new Rectangle(0, 0, 200, 60), StringTool.Alignment.Right, Color.White);
                StringTool.DrawString(spriteBatch, DataSystem.fontCourierNew, "Black: " + black.HP.ToString(), new Rectangle(Util.screenWidth - 200, 0, Util.screenWidth, 60), StringTool.Alignment.Left, Color.White);
                spriteBatch.End();
                graphicsDevice.DepthStencilState = DepthStencilState.Default;

                spriteBatch.Begin();
                white.Draw(camera);
                black.Draw(camera);
                landscape.Draw(gameTime, graphicsDevice, camera);
                spriteBatch.End();
                graphicsDevice.DepthStencilState = DepthStencilState.Default;
            }
            else
            {
                spriteBatch.Begin();
                if (dieSide == 0)
                    StringTool.DrawString(spriteBatch, DataSystem.fontDavida, "Black WIN this battle", new Rectangle(0, 0, Util.screenWidth, Util.screenHeight), StringTool.Alignment.Center, new Color(t * 4, t * 4, t * 4));
                else
                    StringTool.DrawString(spriteBatch, DataSystem.fontDavida, "White WIN this battle", new Rectangle(0, 0, Util.screenWidth, Util.screenHeight), StringTool.Alignment.Center, new Color(t * 4, t * 4, t * 4));
                spriteBatch.End();
                graphicsDevice.DepthStencilState = DepthStencilState.Default;
            }
        }
开发者ID:nguoihocnghe,项目名称:chessbreaklaw,代码行数:28,代码来源:SceneBattle.cs

示例15: StarDraw

 public void StarDraw(SpriteBatch spriteBatch, Vector2 location)
 {
     Rectangle sourceRectangle = new Rectangle((int)MarioSpriteConstants.FIRELEFTJUMPSOURCE.X, (int)MarioSpriteConstants.FIRELEFTJUMPSOURCE.Y,
         (int)MarioSpriteConstants.FIRELEFTJUMPWIDTHHEIGHT.X, (int)MarioSpriteConstants.FIRELEFTJUMPWIDTHHEIGHT.Y);
     Rectangle destinationRectangle = new Rectangle((int)location.X, (int)location.Y,
         (int)MarioSpriteConstants.FIRELEFTJUMPWIDTHHEIGHT.X, (int)MarioSpriteConstants.FIRELEFTJUMPWIDTHHEIGHT.Y);
     if (starDrawCounter < MarioSpriteConstants.STARDRAWBROWNCOUNTER)
     {
         spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, ScreenScaler.ScalingMatrix);
         spriteBatch.Draw(spriteSheet, destinationRectangle, sourceRectangle, Color.Brown);
         spriteBatch.End();
         starDrawCounter++;
     }
     else if (starDrawCounter > MarioSpriteConstants.STARDRAWBROWNCOUNTER && starDrawCounter < MarioSpriteConstants.STARDRAWYELLOWGREENCOUNTER)
     {
         spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, ScreenScaler.ScalingMatrix);
         spriteBatch.Draw(spriteSheet, destinationRectangle, sourceRectangle, Color.YellowGreen);
         spriteBatch.End();
         starDrawCounter++;
     }
     else
     {
         spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, ScreenScaler.ScalingMatrix);
         spriteBatch.Draw(spriteSheet, destinationRectangle, sourceRectangle, Color.Orange);
         spriteBatch.End();
         if (starDrawCounter < MarioSpriteConstants.STARDRAWORANGECOUNTER)
         {
             starDrawCounter++;
         }
         else
         {
             starDrawCounter = MarioSpriteConstants.RESETTOZERO;
         }
     }
 }
开发者ID:Bartholomew-m134,项目名称:BuckeyeGameEngine,代码行数:35,代码来源:FireLeftJumpingMarioSprite.cs


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