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


C# Graphics.SpriteBatch类代码示例

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


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

示例1: Human

        public Human(Game game, SpriteBatch screenSpriteBatch,
            PlayerSide playerSide)
            : base(game, screenSpriteBatch)
        {
            string idleTextureName = "";
            this.playerSide = playerSide;

            if (playerSide == PlayerSide.Left)
            {
                catapultPosition = new Vector2(140, 332);
                idleTextureName = "Textures/Catapults/Blue/blueIdle/blueIdle";
            }
            else
            {
                catapultPosition = new Vector2(600, 332);
                spriteEffect = SpriteEffects.FlipHorizontally;
                idleTextureName = "Textures/Catapults/Red/redIdle/redIdle";
            }

            Catapult = new Catapult(game, screenSpriteBatch,
                                    idleTextureName, catapultPosition,
                                    spriteEffect,
                                    playerSide == PlayerSide.Left
                                        ? false : true, true);
        }
开发者ID:VoronFX,项目名称:SummerPractice,代码行数:25,代码来源:Human.cs

示例2: Draw

 public void Draw(SpriteBatch spriteBatch)
 {
     if (active)
         {
             pickupAnimation.Draw(spriteBatch);
         }
 }
开发者ID:cw100,项目名称:ThreeThingGame131115,代码行数:7,代码来源:Pickup.cs

示例3: Draw

 public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     if (sprite != null && visible)
     {
         spriteBatch.Draw(sprite, position, null, Color.White, 0, Vector2.Zero, new Vector2(1, spriteScale), SpriteEffects.None, 0);
     }
 }
开发者ID:Chartle,项目名称:Gameprogrammeren-Practica,代码行数:7,代码来源:GameObject.cs

示例4: RenderPolygone

 public static void RenderPolygone(SpriteBatch spriteBatch, Texture2D texture, Polygon polygon, int lineThickness, Color color)
 {
     for (int i = 0; i < polygon.Points.Count; ++i)
     {
         RenderLine(spriteBatch, texture, polygon.Points[i], polygon.Edges[i], 1, lineThickness, color);
     }
 }
开发者ID:Norskan,项目名称:Playground,代码行数:7,代码来源:RenderUtil.cs

示例5: Draw

        public virtual void Draw(SpriteBatch spriteBatch)
        {
            float left = Position.X + (EdgeTexture.Height / 2.0f);
            float top = Position.Y + (EdgeTexture.Height / 2.0f);
            float right = left + Dimensions.X - EdgeTexture.Height;
            float bottom = top + Dimensions.Y - EdgeTexture.Height;

            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(left, top), new Vector2(right, top), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(left, top), new Vector2(left, bottom), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(left, bottom), new Vector2(right, bottom), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(right, top), new Vector2(right, bottom), 1.0f, EdgeTint, RenderDepth);

            if (CornerTexture != null)
            {
                spriteBatch.Draw(CornerTexture, new Vector2(left, top), null, EdgeTint, 0.0f, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(right, top), null, EdgeTint, MathHelper.PiOver2, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(right, bottom), null, EdgeTint, MathHelper.Pi, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(left, bottom), null, EdgeTint, MathHelper.Pi * 1.5f, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
            }

            if (BackgroundTexture != null)
            {
                Rectangle area = new Rectangle((int)left, (int)top, (int)(right - left),(int)(bottom - top));
                spriteBatch.Draw(BackgroundTexture, area, null, BackgroundTint, 0.0f, Vector2.Zero, SpriteEffects.None, RenderDepth + 0.005f);
            }
        }
开发者ID:Ben-P-Leda,项目名称:Bopscotch-Editor,代码行数:26,代码来源:Box.cs

示例6: Render

        public void Render(SpriteBatch spriteBatch)
        {
            SmoothScroll();

            int xLoop = (int)(drawArea.Width / tileSize.X);
            if (xLoop >= tiles.Length) xLoop = tiles.Length;

            for (int x = 0; x < xLoop; x++)
            {
                int yLoop = (int)(drawArea.Height / tileSize.Y);
                if (yLoop >= tiles[x].Length) yLoop = tiles[x].Length;

                for (int y = 0; y < yLoop; y++)
                {
                    float xpos = ((x * tileSize.X) + drawOffset.X) + drawArea.X;
                    float ypos = ((y * tileSize.Y) + drawOffset.Y) + drawArea.Y;

                    if (tileOffset.X < 0) tileOffset.X = 0;
                    if (tileOffset.Y < 0) tileOffset.Y = 0;
                    if ((tileOffset.Y + y) >= tiles[x].Length) tileOffset.Y = MaxOffset('Y', x);
                    if ((tileOffset.X + x) >= tiles.Length) tileOffset.X = MaxOffset('X', 0);

                    tiles[x + tileOffset.X][y + tileOffset.Y].Prepare(new Vector2(xpos, ypos), false);
                    tiles[x + tileOffset.X][y + tileOffset.Y].Render(spriteBatch);
                }
            }
        }
开发者ID:thestonefox,项目名称:Project-Xna,代码行数:27,代码来源:Map.cs

示例7: DrawFlagScore

        public void DrawFlagScore(SpriteBatch spriteBatch, GameTime gameTime, float stoppingHeight)
        {
            scoreOrigin = ScoreFont.MeasureString(scoreText) / GameValues.ScoreSpriteScoreOriginOffset;

            spriteBatch.DrawString(ScoreFont, scoreText, new Vector2(Position.X, Position.Y - GameValues.ScoreSpriteDrawFlagScoreYOffset), Color.White, 0, scoreOrigin, 0.4f, SpriteEffects.None, 0f);

            if (Position.Y > stoppingHeight)
            {
                Position = new Vector2(Position.X, Position.Y - GameValues.ScoreSpriteDrawFlagScoreDropOffet);
            }
            else if (Position.Y <= stoppingHeight)
            {
                //Position.Y = stoppingHeight;
                Position = new Vector2(Position.X, stoppingHeight);
                if (scoreBuffer <= 0)
                {
                    scoreBuffer = GameValues.ScoreSpriteScoreBuffer;
                    ScoringOn = !ScoringOn;
                }
                else
                {
                    scoreBuffer--;
                }
            }
        }
开发者ID:BoltThrower,项目名称:Super-Mario-World-1-1,代码行数:25,代码来源:ScoreSprite.cs

示例8: debugDraw

 public void debugDraw(SpriteBatch spritebatch, Texture2D texture)
 {
     foreach (Node nod in nodes){
         Vector2 adjustedPos = new Vector2(nod.Position.X - texture.Width/2, nod.Position.Y - texture.Height/2);
         spritebatch.Draw (texture, adjustedPos, Color.White);
     }
 }
开发者ID:fordream,项目名称:Octo-concurrency,代码行数:7,代码来源:PathFinder.cs

示例9: Draw

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

            foreach (Bullet bullet in bulletList)
                bullet.Draw(spriteBatch);
        }
开发者ID:alexanderwieland,项目名称:SmileyTowerDefense,代码行数:7,代码来源:Tower.cs

示例10: Draw

 public void Draw(SpriteBatch spriteBatch)
 {
     foreach (Item item in itemList)
     {
         item.Draw(spriteBatch);
     }
 }
开发者ID:grodranlorth,项目名称:tctk,代码行数:7,代码来源:ItemManager.cs

示例11: draw

 public virtual void draw(TileDrawInfo drawInfo, SpriteBatch spriteBatch)
 {
     switch (drawInfo.tilePart)
     {
         case TilePart.STRUCTURE:
             foreach (Drawable structure in structures)
             {
                 adjustedDepthDraw(structure, drawInfo, spriteBatch);
             }
             break;
         case TilePart.SURFACE:
             if (surface == null)
             {
                 break;
             }
             adjustedDepthDraw(surface, drawInfo, spriteBatch);
             break;
         case TilePart.LEFTFACE:
             if (leftFace == null)
             {
                 break;
             }
             adjustedDepthDraw(leftFace, drawInfo, spriteBatch);
             break;
         case TilePart.RIGHTFACE:
             if (rightFace == null)
             {
                 break;
             }
             adjustedDepthDraw(rightFace, drawInfo, spriteBatch);
             break;
     }
 }
开发者ID:flatverse,项目名称:flatsim0,代码行数:33,代码来源:SimpleTileTexture.cs

示例12: Draw

 public void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
     dungeonMap.Draw(spriteBatch);
     player.MapDraw(spriteBatch);
     spriteBatch.End();
 }
开发者ID:Zieroc,项目名称:Poorly_Drawn_Dungeons,代码行数:7,代码来源:LevelManager.cs

示例13: AllDraw

 public void AllDraw(SpriteBatch spriteBatch)
 {
     for (int i = 0; i < Backgrounds.Count; i++)
     {
         Backgrounds[i].Draw(spriteBatch);
     }
 }
开发者ID:glocklueng,项目名称:STM32F4_RF,代码行数:7,代码来源:Background.cs

示例14: RenderingExplosion

 public RenderingExplosion(ContentManager Content)
     : base(Content)
 {
     spriteBatch = Content.ServiceProvider.GetService(typeof(SpriteBatch)) as SpriteBatch;
     explosionTexture = Content.Load<Texture2D>("TroopTexture/explosion");
     stateGame = Content.ServiceProvider.GetService(typeof(StateGame)) as StateGame;
 }
开发者ID:JacopoV,项目名称:Tap---Conquer,代码行数:7,代码来源:RenderingExplosion.cs

示例15: Draw

 public void Draw(SpriteBatch spriteBatch)
 {
     if (this.tupianwenzi.IsShowing)
     {
         this.tupianwenzi.Draw(spriteBatch);
     }
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:7,代码来源:tupianwenziPlugin.cs


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