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


C# SpriteBatch.Draw方法代码示例

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


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

示例1: DrawSelf

		protected override void DrawSelf(SpriteBatch spriteBatch)
		{
			base.DrawSelf(spriteBatch);
			CalculatedStyle space = GetInnerDimensions();
			spriteBatch.Draw(Main.magicPixel, new Rectangle((int)space.X + 10, (int)space.Y + (int)space.Height / 2 + 20, (int)space.Width - 20, 10), new Rectangle(0, 0, 1, 1), new Color(0, 0, 70));
			spriteBatch.Draw(Main.magicPixel, new Rectangle((int)space.X + 10, (int)space.Y + (int)space.Height / 2 + 20, (int)((space.Width - 20) * progress), 10), new Rectangle(0, 0, 1, 1), new Color(200, 200, 70));
		}
开发者ID:DrakoGlyph,项目名称:tModLoader,代码行数:7,代码来源:UILoadProgress.cs

示例2: DrawBorder

 public static void DrawBorder(SpriteBatch sb, Texture2D border, XNARectangle rectangle, float transparency = 1.0f)
 {
     sb.Draw(border, new XNARectangle(rectangle.X, rectangle.Y, rectangle.Width, 1), Color.White * transparency); // Top
     sb.Draw(border, new XNARectangle(rectangle.X, rectangle.Y, 1, rectangle.Height), Color.White * transparency); // Left
     sb.Draw(border, new XNARectangle(rectangle.X, rectangle.Y + rectangle.Height - 1, rectangle.Width, 1), Color.White * transparency); // Bottom
     sb.Draw(border, new XNARectangle(rectangle.X + rectangle.Width - 1, rectangle.Y, 1, rectangle.Height), Color.White * transparency); // Right
 }
开发者ID:Jaex,项目名称:Terraria-API,代码行数:7,代码来源:DrawingHelper.cs

示例3: Draw

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(background, drawRect, Color.White);
            spriteBatch.End();
            spriteBatch.Begin();
            GraphicsDevice g = spriteBatch.GraphicsDevice;
            Viewport defaultViewport = g.Viewport;
            Viewport drawViewport = defaultViewport;
            drawViewport.X = drawRect.X;
            drawViewport.Y = drawRect.Y;
            drawViewport.Width = drawRect.Width;
            drawViewport.Height = drawRect.Height;
            g.Viewport = drawViewport;

            GraphicsDevice graphics = spriteBatch.GraphicsDevice;
            graphics.DepthStencilState = DepthStencilState.Default;

            if (model != null)
            {
                model.Draw(camera, info);
            }
            g.Viewport = defaultViewport;
            if (isConflict)
            {
                spriteBatch.Draw(ngTexture, drawRect, Color.White);
            }
        }
开发者ID:hirama-akihiro,项目名称:DropFight,代码行数:27,代码来源:CharactorPreview.cs

示例4: Draw

 public void Draw(SpriteBatch batch)
 {
     batch.Draw(_socketSprite.Texture, _center, null, Color.White, 0f,
                _socketSprite.Origin, 1f, SpriteEffects.None, 0f);
     batch.Draw(_stickSprite.Texture, _position, null, Color.White, 0f,
                _stickSprite.Origin, 1f, SpriteEffects.None, 0f);
 }
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:7,代码来源:VirtualStick.cs

示例5: Draw

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(TitleScreenTexture, Vector2.Zero, null, backgroundCurrentColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
            spriteBatch.Draw(TitleTextJapanese, Vector2.Zero, null, text1CurrentColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, .9f);
            spriteBatch.Draw(TitleTextEnglish, Vector2.Zero, null, text2CurrentColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, .8f);

            if(!HelpShown && !CreditsShown)
                spriteBatch.DrawString(titlescreenFont, "Press ENTER to begin", new Vector2((925f / 2f) - (titlescreenFont.MeasureString("Press ENTER to begin").X / 2f), 500), startTextColor);

            if (fadephase == 2 && !HelpShown && !CreditsShown)
            {
                spriteBatch.DrawString(titlescreenFont, "Press C for credits", new Vector2((925f) - (titlescreenFont.MeasureString("Press C for credits").X + 30), 605), Color.Gray);
                spriteBatch.DrawString(titlescreenFont, "Press H for help", new Vector2((925f) - (titlescreenFont.MeasureString("Press H for help").X + 30), 620), Color.Gray);
            }

            if (HelpShown)
            {
                spriteBatch.Draw(HelpTexture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            }
            else if (CreditsShown)
            {
                spriteBatch.Draw(CreditsTexture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            }

            spriteBatch.DrawString(titlescreenFont, cheatText, new Vector2((925f / 2f) - (titlescreenFont.MeasureString(cheatText).X / 2f), 600), cheatTextCurrentColor);
        }
开发者ID:cmark89,项目名称:AsteroidRebuttal,代码行数:26,代码来源:TitleScene.cs

示例6: Draw

        //Actual game, health checking, and update healthbar.
        public void Draw(SpriteBatch spriteBatch)
        {
            if (gameStarted)
            {

                score.Draw(spriteBatch);
                slider.Draw(spriteBatch);
                if (disconnected)
                {
                    spriteBatch.DrawString(font, "DISCONNECTED", new Vector2(1000, 500), Color.Red);
                }

                //takes care of drawing the health in the form of hearts, every hearth represents 25% health
                int hearts = (int)Math.Ceiling((double)dummy.Health / 25);
                //Loops throught the number of full hearts that should be rendered, moving every heart 100px forward
                for (int i = 0; i < hearts; i++)
                {
                    spriteBatch.Draw(HeartFull, new Vector2(20 + (i * 100), 20), Color.White);
                }
                //draws the empty hearts, moves from the right to the left, decreasing the posistion of every heart by 100px
                for (int i = hearts; i <= 3; i++)
                {
                    spriteBatch.Draw(HeartEmpty, new Vector2(320 - ((3 - i) * 100), 20), Color.White);

                }
            }
            else
            {
                    spriteBatch.DrawString(font, "Druk op de knop op de pop", new Vector2(1000, 500), Color.Black);
            }
        }
开发者ID:Bonemind,项目名称:pulsed,代码行数:32,代码来源:Playing.cs

示例7: Draw

        public void Draw(ISet<State> states, SpriteBatch spriteBatch, XnaRectangle position, XnaColor color)
        {
            int rowTopHeight = _centerTop.Height;
            int rowBottomHeight = _centerBottom.Height;
            int rowCenterHeight = position.Height - rowTopHeight - rowBottomHeight;

            int startY = position.Top;
            int rowCenterTop = startY + rowTopHeight;
            int rowBottomTop = startY + position.Height - rowBottomHeight;

            int colLeftWidth = _leftCenter.Width;
            int colRightWidth = _rightCenter.Width;
            int colCenterWidth = position.Width - colLeftWidth - colRightWidth;

            int startX = position.Left;
            int colCenterLeft = startX + colLeftWidth;
            int colRightLeft = startX + position.Width - colRightWidth;

            spriteBatch.Draw(_texture, new XnaRectangle(startX, startY, colLeftWidth, rowTopHeight), _leftTop, color);
            spriteBatch.Draw(_texture, new XnaRectangle(startX, rowCenterTop, colLeftWidth, rowCenterHeight), _leftCenter, color);
            spriteBatch.Draw(_texture, new XnaRectangle(startX, rowBottomTop, colLeftWidth, rowBottomHeight), _leftBottom, color);
            spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, startY, colCenterWidth, rowTopHeight), _centerTop, color);
            spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, rowCenterTop, colCenterWidth, rowCenterHeight), _center, color);
            spriteBatch.Draw(_texture, new XnaRectangle(colCenterLeft, rowBottomTop, colCenterWidth, rowBottomHeight), _centerBottom, color);
            spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, startY, colRightWidth, rowTopHeight), _rightTop, color);
            spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, rowCenterTop, colRightWidth, rowCenterHeight), _rightCenter, color);
            spriteBatch.Draw(_texture, new XnaRectangle(colRightLeft, rowBottomTop, colRightWidth, rowBottomHeight), _rightBottom, color);
        }
开发者ID:powerdude,项目名称:xamarin-forms-xna,代码行数:28,代码来源:NinePatchImage.cs

示例8: Draw

        public static void Draw(GameTime gameTime, Texture2D texture, SpriteBatch batch)
        {
            // DRAW SCORE
            var rectGear = new Rectangle(448, 640, 64, 64);
            batch.Draw(texture, new Vector2(0, 0), rectGear, Color.Goldenrod);
            var score = String.Format("x{0}", Game1.player.GearCount);
            batch.DrawString(Game1.font, score, new Vector2(64, 0), Color.Black);

            int i = 0;

            batch.DrawString(Game1.font, "               GAME OVER  ",   new Vector2(100, 50 * i++), Color.Black);
            batch.DrawString(Game1.font, "Students:       Ben Branch", new Vector2(100, 50 * i++), Color.White);
            batch.DrawString(Game1.font, "            Addison Denchik", new Vector2(100, 50 * i++), Color.White);
            batch.DrawString(Game1.font, "             Joshua Gold", new Vector2(100, 50 * i++), Color.White);
            batch.DrawString(Game1.font, "              Aaron Kimbrell", new Vector2(100, 50 * i++), Color.White);
            batch.DrawString(Game1.font, "              Micki Salkin", new Vector2(100, 50 * i++), Color.White);
            batch.DrawString(Game1.font, "Counselors:  Laynie Boland", new Vector2(100, 50 * i++), Color.White);
            batch.DrawString(Game1.font, "              Derek Garde", new Vector2(100, 50 * i++), Color.White);
            batch.DrawString(Game1.font, "Instructor:  Joseph Hall", new Vector2(100, 50 * i++), Color.White);

            Vector2 origin = new Vector2(64, 0);
            float rotate = MathHelper.ToRadians(-90);
            Vector2 locDeadGuy = new Vector2(250,0);
            Rectangle rectStanding = new Rectangle(128, 512, 64, 128);
            batch.Draw(texture, locDeadGuy, rectStanding, Color.White, rotate, origin, 1, SpriteEffects.None, 0);
        }
开发者ID:CodeCamps,项目名称:Camp2012,代码行数:26,代码来源:gameoverscreen.cs

示例9: Draw

        public override void Draw(SpriteBatch sprite)
        {
            //draw the box
            //if hovered, show text at center
            switch (currentState)
            {
                case ButtonState.MOUSE_OUT:
                    sprite.Draw(buttonTexture, position, null, Color.Transparent, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
                    break;
                case ButtonState.HOVERED:
                    sprite.Draw(buttonTexture, position, null, Color.Transparent, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
                    //if hovered show text
                    break;
            }

            //draw the text
            if (this.showText)
            {
                switch (currentState)
                {
                    case ButtonState.MOUSE_OUT:
                        sprite.DrawString(fontStyle, label, stringPosition, Color.Black, 0f, stringOrigin, 1f, SpriteEffects.None, 0f);
                        break;
                    case ButtonState.HOVERED:
                        sprite.DrawString(fontStyle, label, stringPosition, Color.White, 0f, stringOrigin, 1f, SpriteEffects.None, 0f);
                        break;
                }
            }
        }
开发者ID:Kairna,项目名称:TouchAndPlay,代码行数:29,代码来源:BasicButton.cs

示例10: Draw

 public void Draw(SpriteBatch spriteBatch, GameTime time)
 {
     if(active && (this is Player || this is Enemy || this is Rock))
         spriteBatch.Draw(texture, position, new Rectangle(0,0,texture.Width,texture.Height), color, rotation, Vector2.Zero, scale, spriteEffects, depth);
     if(active && this is Shoot)
         spriteBatch.Draw(texture, position, new Rectangle(0, 0,texture.Width,texture.Height), color, rotation, Vector2.Zero, scale, spriteEffects, depth);
 }
开发者ID:markic,项目名称:space-shooter,代码行数:7,代码来源:Sprite.cs

示例11: 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

示例12: Draw

        public void Draw(SpriteBatch spriteBatch, Camera camera)
        {
            #region Draw held animations

            if (Player != null)
            {
                spriteBatch.Draw(WeaponTexture, Player.Movement.Area, Color.White);
            }

            #endregion

            #region Draw live weapons

            foreach (var weapon in LiveWeapons)
            {
                if (weapon.Weapon.Type.Name == "Sword")
                {
                    Vector2 center = new Vector2(weapon.Weapon.Sprite.Center.X, weapon.Weapon.Sprite.Bottom);
                    spriteBatch.Draw(WeaponTexture, camera.FromRectangle(new Rectangle((int)weapon.Location.X, (int)weapon.Location.Y, weapon.Weapon.Sprite.Width, weapon.Weapon.Sprite.Height)), weapon.Weapon.Sprite, Color.White, weapon.Rotation, center, SpriteEffects.None, 0);
                    // Draw hitboxes
                    //spriteBatch.Draw(WeaponTexture, camera.FromRectangle(new Rectangle((int)weapon.currentLocation.UpperLeftCorner().X, (int)weapon.currentLocation.UpperLeftCorner().Y, 5, 5)), Color.White);
                    //spriteBatch.Draw(WeaponTexture, camera.FromRectangle(new Rectangle((int)weapon.currentLocation.UpperRightCorner().X, (int)weapon.currentLocation.UpperRightCorner().Y, 5, 5)), Color.White);
                    //spriteBatch.Draw(WeaponTexture, camera.FromRectangle(new Rectangle((int)weapon.currentLocation.LowerLeftCorner().X, (int)weapon.currentLocation.LowerLeftCorner().Y, 5, 5)), Color.White);
                    //spriteBatch.Draw(WeaponTexture, camera.FromRectangle(new Rectangle((int)weapon.currentLocation.LowerRightCorner().X, (int)weapon.currentLocation.LowerRightCorner().Y, 5, 5)), Color.White);
                }
                else if (weapon.Weapon.Type.Name == "Arrow")
                {
                    float angle = (float)Geometry.Angle(Vector2.Zero, weapon.Movement.Velocity);
                    spriteBatch.Draw(ArrowTexture, camera.FromRectangle(weapon.Movement.Area), ArrowTexture.Bounds, Color.White, MathHelper.ToRadians(angle + 90f), new Vector2(weapon.Movement.Area.Width / 2, weapon.Movement.Area.Height / 2), SpriteEffects.None, 0);
                }
            }

            #endregion
        }
开发者ID:Shard,项目名称:Blueprint-Client,代码行数:34,代码来源:WeaponPackage.cs

示例13: Draw

        public void Draw(SpriteBatch spriteBatch, int colour)
        {
            sourceRect = new Rectangle((width * colour), 0, width, 96);

            spriteBatch.Begin();

            // Draw Left Wall
            for (int i = 0; i <= 7; i++)
            {
                destRect = new Rectangle(0, (i * 96), width, 96);
                spriteBatch.Draw(image, destRect, sourceRect, Color.White);
            }
            // Draw Right Wall
            for (int i = 0; i <= 7; i++)
            {
                destRect = new Rectangle((game.ScreenRectangle.Width - width), (i * 96), width, 96);
                spriteBatch.Draw(image, destRect, sourceRect, Color.White, 0.0f, new Vector2(0, 0), SpriteEffects.FlipHorizontally, 1.0f);
            }

            // Draw Roof
            for (int i = 0; i <= 9; i++)
            {
                destRect = new Rectangle((i * 96) + width, 0, width, 96);
                spriteBatch.Draw(image, destRect, sourceRect, Color.White, 1.5707f, new Vector2(0, 96), SpriteEffects.None, 1.0f);
            }

            spriteBatch.End();
        }
开发者ID:xrbob,项目名称:BadAssBrickBreaker-VS13,代码行数:28,代码来源:Walls.cs

示例14: DrawGridContent

        public void DrawGridContent(SpriteBatch spriteBatch, Texture2D texture)
        {
            for (int x = 0; x < CountX; x++)
            {
                for (int y = 0; y < CountY; y++)
                {
                    GridEntity currentGrid = GridBox[x, y];

                    switch (currentGrid.Status)
                    {
                        case GridStatus.Mouseover:
                            spriteBatch.Draw(texture, currentGrid.Rect, MouseoverColor);
                            break;
                        case GridStatus.Occupied:
                            spriteBatch.Draw(texture, currentGrid.Rect, OccupiedColor);
                            break;
                        case GridStatus.Vacant:
                            spriteBatch.Draw(texture, currentGrid.Rect, AreaColor);
                            break;
                        case GridStatus.Selected:
                            spriteBatch.Draw(texture, currentGrid.Rect, currentGrid.Color);
                            break;
                    }
                }
            }
        }
开发者ID:ofjoydivision,项目名称:Grid-Game,代码行数:26,代码来源:GridSheet.cs

示例15: DrawRectangle

 public void DrawRectangle(SpriteBatch spriteBatch, Rectangle rectangle, Color color)
 {
     spriteBatch.Draw(EmptyTexture(), new Rectangle(rectangle.X, rectangle.Y, Configuration.LineWidth, rectangle.Height + Configuration.LineWidth), color);
     spriteBatch.Draw(EmptyTexture(), new Rectangle(rectangle.X, rectangle.Y, rectangle.Width + Configuration.LineWidth, Configuration.LineWidth), color);
     spriteBatch.Draw(EmptyTexture(), new Rectangle(rectangle.X + rectangle.Width, rectangle.Y, Configuration.LineWidth, rectangle.Height + Configuration.LineWidth), color);
     spriteBatch.Draw(EmptyTexture(), new Rectangle(rectangle.X, rectangle.Y + rectangle.Height, rectangle.Width + Configuration.LineWidth, Configuration.LineWidth), color);
 }
开发者ID:Vergilreborn,项目名称:LunarIllusions,代码行数:7,代码来源:ContentConfiguration.cs


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