本文整理汇总了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);
}
示例2: Draw
public void Draw(SpriteBatch spriteBatch)
{
if (active)
{
pickupAnimation.Draw(spriteBatch);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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--;
}
}
}
示例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);
}
}
示例9: Draw
public override void Draw(SpriteBatch spriteBatch)
{
base.Draw(spriteBatch);
foreach (Bullet bullet in bulletList)
bullet.Draw(spriteBatch);
}
示例10: Draw
public void Draw(SpriteBatch spriteBatch)
{
foreach (Item item in itemList)
{
item.Draw(spriteBatch);
}
}
示例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;
}
}
示例12: Draw
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
dungeonMap.Draw(spriteBatch);
player.MapDraw(spriteBatch);
spriteBatch.End();
}
示例13: AllDraw
public void AllDraw(SpriteBatch spriteBatch)
{
for (int i = 0; i < Backgrounds.Count; i++)
{
Backgrounds[i].Draw(spriteBatch);
}
}
示例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;
}
示例15: Draw
public void Draw(SpriteBatch spriteBatch)
{
if (this.tupianwenzi.IsShowing)
{
this.tupianwenzi.Draw(spriteBatch);
}
}