當前位置: 首頁>>代碼示例>>C#>>正文


C# SpriteBatch.DrawRect方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawRect方法的典型用法代碼示例。如果您正苦於以下問題:C# SpriteBatch.DrawRect方法的具體用法?C# SpriteBatch.DrawRect怎麽用?C# SpriteBatch.DrawRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Graphics.SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.DrawRect方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Draw

        public void Draw(SpriteBatch batch)
        {
            if (IsAlive)
            {
                var color = Faction == Faction.Ally ? Color.Blue : Color.Red;
                batch.DrawRect(Position, 20, color);

                if (currentTarget != null)
                {
                    if (!currentTarget.Faction.IsHostile(Faction))
                        color = Color.Green;

                    var dir = currentTarget.Position - Position;
                    //dir.Normalize();
                    dir *= (AP / 100);

                    batch.DrawLine(Position, Position + dir, color, 2);
                }

            }
        }
開發者ID:xposure,項目名稱:Demo,代碼行數:21,代碼來源:Character.cs

示例2: GoalDraw3072

 void GoalDraw3072(SpriteBatch _spriteBatch)
 {
     _spriteBatch.DrawRect(popupRect, Color.DeepSkyBlue, 2.0f);
     _spriteBatch.DrawString(Assets.daFont, "Congratulations! You made it to 3072! Press Space to remove this message or R to restart.", new Vector2(popupRect.X, popupRect.Y), Color.White);
 }
開發者ID:Coteh,項目名稱:2048Clone,代碼行數:5,代碼來源:Game1.cs

示例3: OverlayDraw

 void OverlayDraw(SpriteBatch _spriteBatch)
 {
     _spriteBatch.DrawRect(topHUDRect, Color.Orange);
     _spriteBatch.DrawString(Assets.daFont, "Score: " + gameBoard.Score, Vector2.Zero, Color.Black);
     _spriteBatch.DrawString(Assets.daFont, "Highscore: " + gameBoard.HighScore, new Vector2(GraphicsDevice.Viewport.Width - 200,0), Color.Black);
 }
開發者ID:Coteh,項目名稱:2048Clone,代碼行數:6,代碼來源:Game1.cs

示例4: GameOverDraw

 void GameOverDraw(SpriteBatch _spriteBatch)
 {
     _spriteBatch.DrawRect(popupRect, Color.Red, 2.0f);
     _spriteBatch.DrawString(Assets.daFont, "Game Over! Press R to try again", new Vector2(popupRect.X,popupRect.Y), Color.Black);
 }
開發者ID:Coteh,項目名稱:2048Clone,代碼行數:5,代碼來源:Game1.cs

示例5: GoalDraw2048

 void GoalDraw2048(SpriteBatch _spriteBatch)
 {
     _spriteBatch.DrawRect(popupRect, Color.Lime, 2.0f);
     _spriteBatch.DrawString(Assets.daFont, "Congratulations! You made it to 2048! Press Space to remove this message or R to restart.", new Vector2(popupRect.X, popupRect.Y), Color.Black);
 }
開發者ID:Coteh,項目名稱:2048Clone,代碼行數:5,代碼來源:Game1.cs

示例6: OnDraw

 protected override void OnDraw(GameTime time, SpriteBatch batch, Vector2 v2Offset)
 {
     if (_v2SelectionBoundInitial == s_v2OutOfBounds) return;
     var v2Start = CursorToFromWorld(_v2SelectionBoundInitial, false);
     var v2End   = CursorPosition;
     batch.DrawRect(v2Start, v2End, Color.Yellow, 2);
 }
開發者ID:zdawson,項目名稱:Marooned,代碼行數:7,代碼來源:HUD.cs

示例7: DrawBoundingBox

 private void DrawBoundingBox(SpriteBatch spriteBatch, Camera camera, Color color, NonAxisAlignedBoundingBox box)
 {
     var blank = StateMachine.Owner.RenderManager.TextureCache.GetResource("blank");
     spriteBatch.DrawRect(blank, box, 5, color);
 }
開發者ID:pquinn,項目名稱:time-sink,代碼行數:5,代碼來源:SelectionEditorState.cs

示例8: Draw

 public void Draw(SpriteBatch _spriteBatch)
 {
     for (int i = 0; i < board.GetLength(0); i++) {
         for (int j = 0; j < board.GetLength(1); j++) {
             if (board[i, j] != 0) {
                 _spriteBatch.DrawRect(tilesRectArr[i, j], colorHolder.GetColor(board[i,j]), 1);
                 _spriteBatch.DrawString(Assets.daFont, "" + board[i, j], new Vector2((i * (boardConfig.tileWidth * scale)) + ((boardConfig.tileWidth * scale) / 3) + position.X, (j * (boardConfig.tileHeight * scale)) + ((boardConfig.tileHeight * scale) / 3) + position.Y), Color.Black);
             }
         }
     }
 }
開發者ID:Coteh,項目名稱:2048Clone,代碼行數:11,代碼來源:GameBoard.cs

示例9: Draw

 public override void Draw(GameTime time, SpriteBatch batch)
 {
     batch.DrawRect(Tile.PositionRender, Tile.PositionRender + Vector2.One * Tile.TILE_SIZE);
     Sprite.Draw(batch, Rotation, s_v2RotationCenter, float.Epsilon);
 }
開發者ID:zdawson,項目名稱:Marooned,代碼行數:5,代碼來源:Projectile.cs

示例10: Draw

 public override void Draw(SpriteBatch batch)
 {
     batch.DrawRect(Position - Size * 0.5f, Position + Size * 0.5f, Colour);
     batch.DrawText(Font, Label, Position, Colour.Invert(), true);
 }
開發者ID:zdawson,項目名稱:Marooned,代碼行數:5,代碼來源:DebugSpatial.cs


注:本文中的Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawRect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。