本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.Begin方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.Begin方法的具体用法?C# SpriteBatch.Begin怎么用?C# SpriteBatch.Begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.Begin方法的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);
}
示例2: Draw
public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
{
this.Stopwatch.Reset();
this.Stopwatch.Start();
GameManager.Graphics.GraphicsDevice.Clear(CurrentState.BackgroundColor);
foreach (Camera camera in Cameras)
{
GameManager.currentDrawCamera = camera;
GameManager.Graphics.GraphicsDevice.Viewport = camera.Viewport;
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, camera.GetTransformMatrix());
this.CurrentState.Draw(spriteBatch);
spriteBatch.End();
#if(DEBUG)
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, camera.GetTransformMatrix());
DrawCollisionQuad(spriteBatch);
spriteBatch.End();
this.Stopwatch.Stop();
DebugInfo.AddDebugItem("Draw", this.Stopwatch.ElapsedMilliseconds + " ms");
DebugInfo.AddDebugItem("FPS", "" + Math.Round(1 / gameTime.ElapsedGameTime.TotalSeconds));
spriteBatch.Begin();
DebugInfo.Draw(spriteBatch);
spriteBatch.End();
#endif
Node.ResetDrawDepth();
}
}
示例3: 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();
}
示例4: 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);
}
}
示例5: Draw
public void Draw(SpriteBatch spriteBatch)
{
//Draw all the Lights we have added to LightingManager.LightTarget
LightingManager.BeginDrawMainTarget();
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, null, null, null, null, Camera.Get_Transformation());
mapManager.DrawBackground(spriteBatch);
mapManager.DrawMiddle(spriteBatch);
mapManager.DrawForeground(spriteBatch);
EnemyManager.Draw(spriteBatch);
if (Player != null)
Player.Draw(spriteBatch);
spriteBatch.End();
LightingManager.EndDrawingMainTarget();
LightingManager.DrawLitScreen();
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, null, null, null, null, Camera.Get_Transformation());
Camera.Draw(spriteBatch);
spriteBatch.End();
}
示例6: 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();
}
示例7: Draw
public override void Draw(GameTime gameTime)
{
if (starting)
return;
SpriteBatch spriteBatch = new SpriteBatch(Game.GraphicsDevice); // draw pulsing success/failure
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
Rectangle playerRegion = player.GetRegion();
Rectangle relative = player.GetRelativeRegion();
spriteBatch.Draw(fadeTexture, player.GetRegion(), player.GetRelativeRegion(), puzzleSuccess?(new Color(64, 255, 64, fadeAlpha)):(new Color(255, 69, 0, fadeAlpha)));
spriteBatch.End();
base.Draw(gameTime); // draw status bars over fade
if (!puzzleSuccess)
return;
// draw success plus
if (this.countUpdates > 60)
{
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, this.matrix);
spriteBatch.Draw(plusTexture, new Vector2(), player.ColorOf());
spriteBatch.End();
}
Game.GraphicsDevice.ScissorRectangle = this.drawRegion;
RasterizerState rs = new RasterizerState(); // draw success chevron
rs.ScissorTestEnable = true;
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, rs);
spriteBatch.Draw(chevronTexture, chevronPosition + displacement, null, player.ColorOf(), player.ClockwiseAngle(), new Vector2(42,35), 1.0f, SpriteEffects.None, 0);
spriteBatch.End();
}
示例8: Render
public override void Render(SpriteBatch spriteBatch)
{
View view = player.View;
int x = view.ScreenX + view.Width - MaxTextLength - MaxNameLength - Margin;
int y = view.ScreenY + Margin;
bool alreadyStarted = true;
try {
spriteBatch.End();
} catch (InvalidOperationException) {
alreadyStarted = false;
}
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
foreach (Resource resource in player.Resources) {
drawText(resource.Type + ": ", font, x, y, spriteBatch);
drawText(resource.Quantity.ToString(), font, x + MaxNameLength, y, spriteBatch);
y += Margin + TextHeight;
}
spriteBatch.End();
if (alreadyStarted)
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.None);
}
示例9: 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();
}
}
示例10: Draw
public void Draw(SpriteBatch sb)
{
sb.Begin();
sb.Draw(pauseBackground, new Rectangle(0, 0, 1920, 1080), c);
sb.End();
sb.Begin();
sb.Draw(resumeButton, new Rectangle(565, 490, 800, 100), c);
sb.Draw(titleButton, new Rectangle(565, 615, 800, 100), c);
sb.Draw(quitButton, new Rectangle(565, 740, 800, 100), c);
sb.End();
if (highlightedData != null)
{
sb.Begin();
sb.Draw(highlightedOption, highlightedData, Color.White);
sb.End();
}
sb.Begin();
sb.Draw(resumeButton, new Rectangle(560, 485, 800, 100), c);
sb.Draw(titleButton, new Rectangle(560, 610, 800, 100), c);
sb.Draw(quitButton, new Rectangle(560, 735, 800, 100), c);
sb.End();
sb.Begin();
sb.Draw(pauseText, new Rectangle(0, 20, 1920, 1080), Color.White);
sb.End();
}
示例11: 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();
}
}
示例12: 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();
}
示例13: 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();
}
示例14: 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;
}
示例15: 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;
}
}