本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DrawRectangle方法的具体用法?C# SpriteBatch.DrawRectangle怎么用?C# SpriteBatch.DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.DrawRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch)
{
switch (_currentMap)
{
case SimulationScreenMap.Urban: _playerGame.UrbanMap.Draw(gameTime); break;
case SimulationScreenMap.Country: _playerGame.CountryMap.Draw(gameTime); break;
case SimulationScreenMap.Ocean: _playerGame.OceanMap.Draw(gameTime); break;
}
spriteBatch.DrawLine(150, 0, 150, graphicsDevice.Viewport.Height, Color.White);
spriteBatch.DrawLine(0, graphicsDevice.Viewport.Height - 100, graphicsDevice.Viewport.Width,
graphicsDevice.Viewport.Height - 100, Color.White);
/* Area selection */
Rectangle areaSelectionUrban = new Rectangle(5, graphicsDevice.Viewport.Height - 148, 43, 43);
Rectangle areaSelectionCountry = new Rectangle(53, graphicsDevice.Viewport.Height - 148, 43, 43);
Rectangle areaSelectionOcean = new Rectangle(101, graphicsDevice.Viewport.Height - 148, 43, 43);
spriteBatch.DrawRectangle(0, graphicsDevice.Viewport.Height - 174, 150, 75, Color.White);
spriteBatch.FillRectangle(areaSelectionUrban, (_currentMap == SimulationScreenMap.Urban ?
Color.LightGray : Color.Gray));
spriteBatch.DrawRectangle(areaSelectionUrban, Color.White);
spriteBatch.FillRectangle(areaSelectionCountry, (_currentMap == SimulationScreenMap.Country ?
Color.LightGray : Color.Gray));
spriteBatch.DrawRectangle(areaSelectionCountry, Color.White);
spriteBatch.FillRectangle(areaSelectionOcean, (_currentMap == SimulationScreenMap.Ocean ?
Color.LightGray : Color.Gray));
spriteBatch.DrawRectangle(areaSelectionOcean, Color.White);
}
开发者ID:jyavoc,项目名称:Project-Gaia,代码行数:28,代码来源:SimulationScreen+(Jacob+Deitloff's+conflicted+copy+2011-03-18).cs
示例2: Draw
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.FillRectangle(Position, Size, BaseColor);
spriteBatch.DrawRectangle(Position, Size, BorderColor);
spriteBatch.DrawString(Font, Label + ": " + CurrentValue + " / " + MaxValue,
new Vector2(Position.X + 1, Position.Y + Size.Y - Font.MeasureString(Label + ": " +
CurrentValue + " / " + MaxValue).Y), TextColor);
}
示例3: Draw
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
if (BackgroundColor.HasValue)
spriteBatch.DrawRectangle(new Rectangle((int)Position.X, (int)Position.Y, Size.X, Size.Y), BackgroundColor.Value * Alpha);
if (BackgroundTexture != null)
spriteBatch.Draw(BackgroundTexture, new Rectangle((int)Position.X, (int)Position.Y, Size.X, Size.Y), Color.White * Alpha);
base.Draw(gameTime, spriteBatch);
}
示例4: Draw
public void Draw(SpriteBatch sb, GameTime gameTime)
{
foreach (Enemy e in Enemies)
{
e.Draw(sb, gameTime);
if (e != closestEnemy) continue;
sb.DrawRectangle(e.HitBox, Color.Red);
/*
Stencil.Write("D: " + Math.Round((e.Center - player.Center).Length(), 1, MidpointRounding.AwayFromZero), sb, e.X + 4, e.Y + e.Height - 3, 0.5f);
Stencil.Write("A: " + Math.Round(MathHelper.ToDegrees(player.Center.Angle(e.Center)), 1, MidpointRounding.AwayFromZero), sb, e.X + 4, e.Y + e.Height + 9, 0.5f);
Stencil.Write("L: " + e.Health, sb, e.X + 4, e.Y + e.Height + 21, 0.5F);
*/
if (e.Center.Y > 0)
sb.DrawLine(e.Center, player.Center, Color.Red);
}
}
示例5: Draw
protected override void Draw()
{
GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.Black);
if (MapEditorGlobals.CurrentActiveTexture == null)
return;
var spriteBatch = new SpriteBatch(GraphicsDevice);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
spriteBatch.Draw(MapEditorGlobals.CurrentActiveTexture, new Vector2(0, 0), Microsoft.Xna.Framework.Color.White);
spriteBatch.DrawRectangle(MapEditorGlobals.RectangleSelectedTiles, Microsoft.Xna.Framework.Color.Yellow, 4f);
spriteBatch.End();
}
示例6: Draw
public override void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, null, null, null, ServiceManager.Camera.GetTransformation());
foreach (var entity in ServiceManager.EntityCollection.Entities)
{
// Local players can be moved automatically, then report their status if needed
var skinComponent = entity.GetComponent<SkinComponent>();
// TODO: Make it so we can get the sprite descriptors from the sprite service.
var spriteDescriptor = entity.GetComponent<SpriteComponent>().SpriteDescriptor;
var transformComponent = entity.GetComponent<TransformComponent>();
Rectangle bbox = new Rectangle(
(int)(transformComponent.LocalPosition.X + spriteDescriptor.BoundingBox.X),
(int)(transformComponent.LocalPosition.Y + spriteDescriptor.BoundingBox.Y),
spriteDescriptor.BoundingBox.Width,
spriteDescriptor.BoundingBox.Height);
spriteBatch.DrawRectangle(bbox, Color.White, 2f);
}
spriteBatch.End();
}
示例7: Draw
public void Draw(SpriteBatch spriteBatch)
{
SpriteEffects spriteEffect;
if (velocity.X < 0)
{
spriteEffect = SpriteEffects.FlipHorizontally;
}
else { spriteEffect = SpriteEffects.None; }
if (Math.Abs(velocity.X) < 30)
{
currentAnimation.Active = false;
currentAnimation.currentFrame = 0;
playerSprite.Flip = spriteEffect;
playerSprite.Draw(spriteBatch);
}
else //we are running
{
currentAnimation.Active = true;
currentAnimation = runningAnimation;
currentAnimation.spriteEffects = spriteEffect;
currentAnimation.Draw(spriteBatch);
}
spriteBatch.DrawRectangle(playerBounds, Color.Red);
#if DEBUG
spriteBatch.DrawRectangle(playerBounds,Color.Red);
#endif
}
示例8: Draw
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
base.Draw(gameTime, spriteBatch);
if (HighlightedMove == null)
return;
var sine = (1.0F + (float)(Math.Sin((float)gameTime.TotalGameTime.TotalSeconds * 6.0F) * 1.0F)) / 2.0F;
spriteBatch.DrawRectangle(GetAnimalRectangle(HighlightedMove.From), Color.Black * Math.Max(0.0F, sine * 0.25F));
spriteBatch.DrawRectangle(GetAnimalRectangle(HighlightedMove.To), Color.Black * Math.Max(0.0F, sine * 0.25F));
}
示例9: Draw
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(this.texture, guidePosition, guideSourceRect, Color.White);
//spriteBatch.Draw(this.texture, guidePosition, Color.White);
// DEBUG: Draw locations of buttons and tabs
if (Settings.SHOW_HITBOXES)
{
Vector2 openButtonPosition, closeButtonPosition, tab1, tab2, tab3, tab4, tabSize;
tabSize = new Vector2(Settings.CALLOUT_TAB_WIDTH, Settings.CALLOUT_TAB_HEIGHT);
if (this.IsLeftward)
{
openButtonPosition = Settings.CALLOUT_OPEN_BUTTON_LEFT;
closeButtonPosition = Settings.CALLOUT_CLOSE_BUTTON_LEFT;
if (this.IsUpsideDown)
{
tab1 = -Settings.CALLOUT_TAB1_BUTTON;
tab2 = -Settings.CALLOUT_TAB2_BUTTON;
tab3 = -Settings.CALLOUT_TAB3_BUTTON;
tab4 = -Settings.CALLOUT_TAB4_BUTTON;
}
else
{
tab1 = Settings.CALLOUT_TAB1_BUTTON_LEFT;
tab2 = Settings.CALLOUT_TAB2_BUTTON_LEFT;
tab3 = Settings.CALLOUT_TAB3_BUTTON_LEFT;
tab4 = Settings.CALLOUT_TAB4_BUTTON_LEFT;
}
}
else
{
openButtonPosition = Settings.CALLOUT_OPEN_BUTTON;
closeButtonPosition = Settings.CALLOUT_CLOSE_BUTTON;
if (this.IsUpsideDown)
{
tab1 = -Settings.CALLOUT_TAB1_BUTTON_LEFT;
tab2 = -Settings.CALLOUT_TAB2_BUTTON_LEFT;
tab3 = -Settings.CALLOUT_TAB3_BUTTON_LEFT;
tab4 = -Settings.CALLOUT_TAB4_BUTTON_LEFT;
}
else
{
tab1 = Settings.CALLOUT_TAB1_BUTTON;
tab2 = Settings.CALLOUT_TAB2_BUTTON;
tab3 = Settings.CALLOUT_TAB3_BUTTON;
tab4 = Settings.CALLOUT_TAB4_BUTTON;
}
}
if (this.CurrentState == Guide.GuideState.CLOSED)
{
spriteBatch.DrawCircle(this.ParentZoomCircle.position + openButtonPosition, Settings.CALLOUT_DETECTION_RADIUS, 64, Color.Pink);
}
else if (this.CurrentState == Guide.GuideState.OPEN)
{
spriteBatch.DrawCircle(this.ParentZoomCircle.position + closeButtonPosition, Settings.CALLOUT_DETECTION_RADIUS, 64, Color.Pink);
spriteBatch.DrawRectangle(this.ParentZoomCircle.position + new Vector2(tab1.X - tabSize.X / 2, tab1.Y - tabSize.Y / 2), tabSize, Color.Pink, 1f);
spriteBatch.DrawRectangle(this.ParentZoomCircle.position + new Vector2(tab2.X - tabSize.X / 2, tab2.Y - tabSize.Y / 2), tabSize, Color.Pink, 1f);
spriteBatch.DrawRectangle(this.ParentZoomCircle.position + new Vector2(tab3.X - tabSize.X / 2, tab3.Y - tabSize.Y / 2), tabSize, Color.Pink, 1f);
spriteBatch.DrawRectangle(this.ParentZoomCircle.position + new Vector2(tab4.X - tabSize.X / 2, tab4.Y - tabSize.Y / 2), tabSize, Color.Pink, 1f);
}
}
}
示例10: DrawSelf
public void DrawSelf(SpriteBatch spriteBatch, Color color)
{
spriteBatch.DrawRectangle(_bbox, color);
}
示例11: Draw
public void Draw(SpriteBatch sb, GameTime gameTime)
{
background.Draw(sb);
sb.DrawRectangle(player.HitBox, Color.Red);
phases.Draw(sb, gameTime);
player.Draw(sb, gameTime);
}
示例12: Draw
public override void Draw( SpriteBatch spriteBatch, float alpha ) {
Color dynamicColor = new Color( new Vector4( ColorFgDefault.ToVector3(), alpha ) );
Vector2 drawPos = Position;
Vector2 textSize = SpriteFont.MeasureString( Text );
string[] Lines = Text.Split( new char[] { '\n' } );
if( ColorBgDefault != Color.Transparent ) {
Color dynBg = new Color( new Vector4( ColorBgDefault.ToVector3(), alpha ) );
mButtonArea = new Rectangle( (int)Position.X - Value, (int)Position.Y - Value, ControlSize.X, ControlSize.Y );
if( ControlSize.X == 0 )
mButtonArea.Width = (int)textSize.X + 5;
if( ControlSize.Y == 0 )
mButtonArea.Height = (int)textSize.Y + 5;
if( mTextureBlank == null )
mTextureBlank = EngineCore.ContentLoader.Load<Texture2D>( @"Interface\blank" );
spriteBatch.Draw( mTextureBlank, mButtonArea, dynBg );
if( BorderColor != Color.Transparent ) {
Texture2D tex = DrawHelper.Rect2Texture( 1, 1, 0, BorderColor );
spriteBatch.DrawRectangle( tex, mButtonArea, 1, BorderColor );
}
} else
mButtonArea = new Rectangle( mButtonArea.X, mButtonArea.Y, ControlSize.X, ControlSize.Y );
for( int i = 0; i < Lines.Length; i++ ) {
if( i > 0 )
drawPos.Y += SpriteFont.LineSpacing;
spriteBatch.DrawString( SpriteFont, Lines[ i ], drawPos, dynamicColor );
}
}
示例13: Draw
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
spriteBatch.FillRectangle(Position, Size, (Hovered ? Color.LightBlue : Color.Blue));
spriteBatch.DrawRectangle(Position, Size, Color.Black);
}
示例14: DrawWorldViewPort
//.........这里部分代码省略.........
for (int i = 0; i < viewPortInfo.TileCountX; i++)
{
for (int j = 0; j < viewPortInfo.TileCountY; j++)
{
int tileX = (int)(i + viewPortInfo.pxTopLeftX / Map.TileWidth);
int tileY = (int)(j + viewPortInfo.pxTopLeftY / Map.TileHeight);
int tileGid = tileLayer[tileX, tileY];
Rectangle pxTileDestRect = new Rectangle(
(int) Math.Ceiling(i * viewPortInfo.pxTileWidth - viewPortInfo.pxDispX * viewPortInfo.ActualZoom),
(int) Math.Ceiling(j * viewPortInfo.pxTileHeight - viewPortInfo.pxDispY * viewPortInfo.ActualZoom),
(int) viewPortInfo.pxTileWidth,
(int) viewPortInfo.pxTileHeight
);
if (tileGid != 0 && tileGid != -1) // NULL or INVALID Tile Gid is ignored
{
Tile tile = Map.Tiles[tileGid];
spriteBatch.Draw(
tile.sourceTexture,
pxTileDestRect,
tile.SourceRectangle,
layerColor,
0, Vector2.Zero,
SpriteEffects.None,
depth
);
}
// DRAW THE TILE LAYER GRID IF ENABLE
if (DrawingOptions.ShowTileGrid && layerIndex == Map.TileLayers.Count - 1)
spriteBatch.DrawRectangle(pxTileDestRect, Color.Black, 0);
}
}
}
}
}
spriteBatch.End();
OverallPerformance.StopTiming("TileRenderingTime");
// Calculate the entity Displacement caused by pxTopLeft at a global scale to prevent jittering.
// Each entity should be displaced by the *same amount* based on the pxTopLeftX/Y values
// this is to prevent entities 'jittering on the screen' when moving the camera.
float globalDispX = (int) Math.Ceiling(viewPortInfo.pxTopLeftX * viewPortInfo.ActualZoom);
float globalDispY = (int) Math.Ceiling(viewPortInfo.pxTopLeftY * viewPortInfo.ActualZoom);
// DRAW VISIBLE REGISTERED ENTITIES
OverallPerformance.RestartTiming("TotalEntityRenderTime");
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, samplerState, null, null);
{
EntitiesOnScreen = Collider.GetIntersectingEntites(new FRectangle(viewPortInfo.pxViewPortBounds));
// DRAW EACH ENTITIY THAT IS WITHIN THE SCREENS VIEWPORT
foreach (Entity entity in EntitiesOnScreen)
{
EntityRenderPerformance.RestartTiming(entity.Name);
if (!entity.Visible) continue;
entity.IsOnScreen = true;
// Determine the absolute position on the screen for entity position and the bounding box.
Vector2 pxAbsEntityPos = new Vector2(
entity.Pos.X * viewPortInfo.ActualZoom - globalDispX,
示例15: Draw
public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
{
spriteBatch.Begin();
player.Draw(spriteBatch, gameTime);
//Kenneth: Test av tegning av "Rock", merk at draw i Sprite nå har fått overloaded draw med scaling
rock.Draw(spriteBatch, new Vector2(Game.Window.ClientBounds.Width / 2, Game.Window.ClientBounds.Height / 2),gameTime, 0.7f);
particleEmitter.Draw(spriteBatch, gameTime); //Bare test av denne particleEmitter-tingen. Fungerer ikke bra nok.
//Her tegner jeg gridnettet som Debugging, trenger naturlig nok ikke å være synlig i spillverden :)
for (int i = 0; i < collisionGrid.Count; i++ )
{
spriteBatch.DrawRectangle(collisionGrid.ElementAt(i).rectangle, collisionGrid.ElementAt(i).Color, 1f);
}
spriteBatch.DrawRectangle(mouseCollisionRectangle, Color.Green);
if (pauseMenu.Open)
{
pauseMenu.Draw(spriteBatch, gameTime);
}
spriteBatch.End();
}