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


C# SpriteBatch.DrawString方法代码示例

本文整理汇总了C#中SpriteBatch.DrawString方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DrawString方法的具体用法?C# SpriteBatch.DrawString怎么用?C# SpriteBatch.DrawString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpriteBatch的用法示例。


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

示例1: Draw

		/// <summary>
		/// Draws
		/// </summary>
		/// <param name="batch"></param>
		public override void Draw(SpriteBatch batch)
		{
			base.Draw(batch);


			// Display message
			if (Hero == null)
			{
				batch.DrawString(GUI.MenuFont, new Point(26, 58), RectangleColor, Message);
			}
			else
			{
				//batch.DrawString(Camp.Font, new Point(16, 76), Color.White, "0 of 0 remaining.");
			}

			#region Draw heroes
			for (int y = 0; y < 3; y++)
			{
				for (int x = 0; x < 2; x++)
				{
					Hero hero = GameScreen.Team.Heroes[y * 2 + x];
					if (hero == null)
						continue;

					float col = (float)Math.Sin(1.0f);
					batch.DrawRectangle(new Rectangle(366 + x * 144, 2 + y * 104, 130, 104), Color.White);
					batch.DrawRectangle(new Rectangle(367 + x * 144, 4 + y * 104, 128, 101), Color.White);
				}
			}
			#endregion
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:35,代码来源:DropCharacterWindow.cs

示例2: Draw

 public override void Draw(SpriteBatch spriteBatch, GameTime time)
 {
     if (!Visible) return;
     var tex = (IsChecked) ? Textures[0] : Textures[1];
     tex = (Enabled) ? tex : (IsChecked) ? Textures[2] : Textures[3];
     spriteBatch.DrawTexture(tex, new Rectangle(Position.X, Position.Y, Size.Width, Size.Height), Color.White);
     spriteBatch.DrawString(Text, Font, new Vector2(Position.X + 35, Position.Y + 5), Color);
 }
开发者ID:KaskadekingDE,项目名称:ChainReact,代码行数:8,代码来源:Checkbox.cs

示例3: Draw

		/// <summary>
		/// Draws the window
		/// </summary>
		/// <param name="batch">Spritebatch handle</param>
		public override void Draw(SpriteBatch batch)
		{
			base.Draw(batch);

			Team team = GameScreen.Team;

			// Display message
			if (Hero == null)
			{
				batch.DrawString(GUI.MenuFont, new Point(26, 58), RectangleColor, Message);
			}
			else
			{
				batch.DrawString(GUI.MenuFont, new Point(16, 76), Color.White, "0 of 0 remaining.");
			}

			#region Draw heroes
			for (int y = 0 ; y < 3 ; y++)
			{
				for (int x = 0 ; x < 2 ; x++)
				{
					Hero hero = team.Heroes[y * 2 + x];
					if (hero == null)
						continue;

					// Draw rectangle around the hero
					if (hero == Hero)
					{
						float col = (float)Math.Sin(1.0f);
						batch.DrawRectangle(new Rectangle(366 + x * 144, 2 + y * 104, 130, 104), Color.White);
						batch.DrawRectangle(new Rectangle(367 + x * 144, 4 + y * 104, 128, 101), Color.White);
					}
					else if (!hero.CheckClass(Filter))
					{
						// Ghost name
						batch.DrawTile(Interface, 31, new Point(368 + 144 * x, y * 104 + 4));
					}
				}
			}
			#endregion
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:45,代码来源:SpellWindow.cs

示例4: Draw

        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (!Visible) return;
            var size = Font.MeasureString(Text);

            spriteBatch.DrawTexture(IsHovered ? _hoveredTexture : _texture,
                 new Rectangle(Position.X, Position.Y, Size.Width, Size.Height));
            spriteBatch.DrawString(Text, Font,
                new Vector2(Position.X + ((Size.Width - size.X) / 2), Position.Y + ((Size.Height - size.Y) / 2)),
                Color.White);
            base.Draw(spriteBatch, gameTime);
        }
开发者ID:KaskadekingDE,项目名称:ChainReact,代码行数:12,代码来源:Button.cs

示例5: Draw

		public override void Draw(SpriteBatch batch) {
			if (base._visible) {
				pos = base.ConvertToWorldPos();
				scale = base.ConvertToWorldScale();
				rotation = base.ConvertToWorldRot();
				batch.SetColor(base._color.r, base._color.g, base._color.b,
						base._alpha);
				LFont font = batch.GetFont();
				batch.SetFont(_spriteFont);
				batch.DrawString(this._text, pos[0], pos[1], scale[0], scale[1],
						_anchor.x, _anchor.y, MathUtils.ToDegrees(rotation),
						batch.GetColor());
				batch.SetFont(font);
				batch.ResetColor();
			}
		}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:16,代码来源:LNLabel.cs

示例6: Draw

        public override void Draw(SpriteBatch sb)
        {
            bBackground.Draw(sb);

            sPixel.Draw(sb);

            sb.DrawString(Game1.sfTemplate, "Minimum Rooms", new Vector2(XOffset, YOffset * 4.5f), Color.White);
            sb.DrawString(Game1.sfTemplate, "Maximum Rooms", new Vector2(XOffset, YOffset * 5.5f), Color.White);

            //  Buttons
            bBack.Draw(sb, Game1.sfFont);
            bControls.Draw(sb, Game1.sfFont);
            #if DESKTOP
            bMusic.Draw(sb, Game1.sfFont);
            #endif
            tbMinRooms.Draw(sb, Game1.sfTemplate);
            tbMaxRooms.Draw(sb, Game1.sfTemplate);
        }
开发者ID:ChocMaltHoney,项目名称:Neuroleptic,代码行数:18,代码来源:Options.cs

示例7: Draw

        public override void Draw(SpriteBatch batch, GameTime time)
        {
            batch.Begin();
            // Draw wood background
            for (var x = 0; x < 11; x++)
            {
                for (var y = 0; y < 8; y++)
                {
                    var tileX = x * ChainReactGame.WabeSize;
                    var tileY = y * ChainReactGame.WabeSize;
                    batch.DrawTexture(_background, new Rectangle(tileX, tileY, ChainReactGame.WabeSize, ChainReactGame.WabeSize));
                }
            }

            // Draw gray game field
            for (var x = 1; x < 7; x++)
            {
                for (var y = 1; y < 7; y++)
                {
                    var tileX = x * ChainReactGame.WabeSize;
                    var tileY = y * ChainReactGame.WabeSize;
                    batch.DrawTexture(_gameAreaTexture, new Rectangle(tileX, tileY, ChainReactGame.WabeSize, ChainReactGame.WabeSize));
                }
            }

            // Draw wabes
            const float cut = (ChainReactGame.WabeSize / 3);
            var fullWabeSizeX = ChainReactGame.WabeSize * _game.GameMap.Wabes.GetLength(0);
            var fullWabeSizeY = ChainReactGame.WabeSize * _game.GameMap.Wabes.GetLength(1);
                foreach (var wabe in _game.GameMap.Wabes)
                {
                    var wabeX = (wabe.X + 1) * ChainReactGame.WabeSize;
                    var wabeY = (wabe.Y + 1) * ChainReactGame.WabeSize;

                    for (var x = 0; x <= 2; x++)
                    {
                        for (var y = 0; y <= 2; y++)
                        {
                            var field = wabe.ConvertVector2ToWabeField(new Vector2(x, y));
                            var texture = SelectTextureFromField(field);
                            var mutltiplicatorX = cut * x;
                            var mutltiplicatorY = cut * y;
                            if (field.Type == WabeFieldType.Center)
                            {
                                var color = wabe.Owner?.Color ?? Color.White;
                                color.A = (wabe.Owner != null) ? (byte)205 : (byte)255;
                                batch.DrawTexture(texture, new Rectangle((wabeX) + mutltiplicatorX, (wabeY) + mutltiplicatorY, cut, cut), color);
                            }
                            else if (field.Type == WabeFieldType.Unused)
                            {
                                var color = wabe.Owner?.Color ?? Color.LightGray;
                                color.A = 128;
                                batch.DrawTexture(texture, new Rectangle((wabeX) + mutltiplicatorX, (wabeY) + mutltiplicatorY, cut, cut), color);
                            }
                            else
                            {
                                batch.DrawTexture(texture,
                                    new Rectangle((wabeX) + mutltiplicatorX, (wabeY) + mutltiplicatorY, cut, cut));
                            }
                            var posX = mutltiplicatorX + wabeX;
                            var posY = mutltiplicatorY + wabeY;
                            // Draw field border
                            if (GameSettings.Instance.FieldLines)
                                batch.DrawTexture(_fieldBorder, new Rectangle(posX, posY, cut, cut));
                        }
                    }
                    // Draw wabe border
                    if (GameSettings.Instance.WabeLines)
                        batch.DrawTexture(_wabeBorder, new Rectangle(wabeX, wabeY, ChainReactGame.WabeSize, ChainReactGame.WabeSize));
                }

            // Draw game border
            if (GameSettings.Instance.BorderLines)
                batch.DrawTexture(_gameBorder, new Rectangle(ChainReactGame.WabeSize, ChainReactGame.WabeSize, fullWabeSizeX, fullWabeSizeY));

            // Draw messages
            if (!string.IsNullOrEmpty(_lastMessage))
            {
                batch.DrawString(!string.IsNullOrEmpty(_game.Message) ? _game.Message : _lastMessage, _font,
                    new Vector2(96, 680), Color.Black);
            }
            else
            {
                if (!string.IsNullOrEmpty(_game.Message))
                {
                    batch.DrawString(_game.Message, _font, new Vector2(96, 680), Color.Black);
                }
            }

            if (!string.IsNullOrEmpty(ResourceManager.LastSoundError))
            {
                batch.DrawString("Failed to play a sound: " + ResourceManager.LastSoundError, _font, new Vector2(96, 720), Color.Red);
            }

            if (_game?.CurrentPlayer != null)
            {
                batch.DrawString(_game.CurrentPlayer.Name + $"'s turn ({_game.CurrentPlayer.GetColorString()}) ({_game.CurrentPlayer.Wins} Wins)", _font, new Vector2(96, 60), Color.Black);
            }

            foreach (var wabe in _game.GameMap.Wabes.Cast<Wabe>().ToList().Where(x => x.AnimationManager.IsRunning).Select(x => x.AnimationManager))
//.........这里部分代码省略.........
开发者ID:KaskadekingDE,项目名称:ChainReact,代码行数:101,代码来源:SingleplayerComponent.cs

示例8: Draw

		/// <summary>
		/// Draws the window
		/// </summary>
		/// <param name="batch">SpriteBatch to use</param>
		public void Draw(CampDialog camp, SpriteBatch batch)
		{
			if (batch == null)
				return;

			// Draw bevel background
			GUI.DrawDoubleBevel(batch, Rectangle, GameColors.Main, GameColors.Light, GameColors.Dark, false);

			// Draw message
			Point point = Rectangle.Location;
			point.Offset(6, 6);
			batch.DrawString(GUI.MenuFont, point, Color.White, Text);

			// Draw buttons
			foreach (ScreenButton button in Buttons)
			{
				Rectangle rect = ClientToScreen(Rectangle.Location, button.Rectangle);
				GUI.DrawDoubleBevel(batch, rect, GameColors.Main, GameColors.Light, GameColors.Dark, false);

				// Text
				point = rect.Location;
				point.Offset(6, 6);
				batch.DrawString(GUI.MenuFont, point, button.TextColor, button.Text);
			}
			
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:30,代码来源:MessageBox.cs

示例9: Draw

		/// <summary>
		/// 
		/// </summary>
		/// <param name="batch"></param>
		public override void Draw(SpriteBatch batch)
		{
			base.Draw(batch);

			// No answer, waiting
			if (Start == DateTime.MinValue)
				return;

			Team team = GameScreen.Team;

			// Number of hour sleeping
			int hours = (int)(DateTime.Now - Start).TotalSeconds;

			// Display
			batch.DrawString(GUI.MenuFont, new Point(26, 58), Color.White, "Hours rested : " + hours);

			foreach (Hero hero in team.Heroes)
			{
				if (hero == null)
					continue;

				// Hero can heal some one ?
				if (hero.CanHeal())
				{

					// Find the weakest hero and heal him
					Hero weakest = team.Heroes[0];
					foreach (Hero h in team.Heroes)
					{
						if (h == null)
							continue;

						if (h.HitPoint.Ratio < weakest.HitPoint.Ratio)
							weakest = h;
					}

					if (weakest.HitPoint.Ratio < 1.0f)
					{
						GameMessage.AddMessage(hero.Name + " casts healing on " + weakest.Name);
						hero.Heal(weakest);
					}
				}
			}
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:48,代码来源:RestPartyWindow.cs

示例10: DrawBackground

		/// <summary>
		/// Draw the background window
		/// </summary>
		/// <param name="batch">Spritebatch to use</param>
		protected void DrawBackground(SpriteBatch batch)
		{
			Rectangle rect = new Rectangle(0, 0, 352, 288);
			GUI.DrawDoubleBevel(batch, rect, GameColors.Main, GameColors.Light, GameColors.Dark, false);

			batch.DrawString(GUI.MenuFont, new Point(8, 10), GameColors.Cyan, Title);
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:11,代码来源:Window.cs

示例11: Draw

 public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     if (!Visible) return;
     spriteBatch.DrawString(Text, Font, Position, Color);
     base.Draw(spriteBatch, gameTime);
 }
开发者ID:KaskadekingDE,项目名称:ChainReact,代码行数:6,代码来源:Label.cs

示例12: Draw

		/// <summary>
		/// Draws the game messages
		/// </summary>
		/// <param name="Batch">Spritebatch handle</param>
		public static void Draw(SpriteBatch batch)
		{

			// Display the last 3 messages
			int i = 0;
			foreach (ScreenMessage msg in GameMessage.Messages)
			{
				batch.DrawString(Font, new Point(8, 360 + i * 12), msg.Color, msg.Message);
				i++;
			}

		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:16,代码来源:GameMessage.cs

示例13: DrawBack

            protected Vector2 DrawBack(SpriteBatch sb)
            {
                Vector2 pos = new Vector2(-4, 0);
                if(top) {
                    Conversation.top.Draw(sb, new Point(-4, 0));
                    try { Conversation.ports[img].Draw(sb, new Point(19, 43)); } catch(KeyNotFoundException) { }

                    if(ShowNameplate) {
                        Conversation.nameplate.Mirror = SpriteEffects.None;
                        Conversation.nameplate.Draw(sb, new Point(0, 191));
                        sb.DrawString(Resources.fonts["04b03m"], name, new Vector2(33, 202), Color.White);
                    }
                } else {
                    Conversation.bottom.Draw(sb, new Point(-4, 403));
                    try { Conversation.ports[img].Draw(sb, new Point(19, 446)); } catch(KeyNotFoundException) { }
                    pos += new Vector2(0, 403);

                    if(ShowNameplate) {
                        Conversation.nameplate.Mirror = SpriteEffects.FlipVertically;
                        Conversation.nameplate.Draw(sb, new Point(0, 365));
                        sb.DrawString(Resources.fonts["04b03m"], name, new Vector2(33, 376), Color.White);
                    }
                }
                return pos + new Vector2(205, 42);
            }
开发者ID:sctjkc01,项目名称:Clocked,代码行数:25,代码来源:Convo.cs

示例14: Draw

            public virtual void Draw(SpriteBatch sb)
            {
                Vector2 pos = DrawBack(sb);

                List<String> words = show.Split(' ').ToList<String>();
                float space = Resources.fonts["04b03m"].MeasureString(" ").X;
                foreach(String word in words) {
                    pos.X += Resources.fonts["04b03m"].MeasureString(word).X;
                    if(pos.X > 770) {
                        pos.X = 205 + Resources.fonts["04b03m"].MeasureString(word).X + space;
                        pos.Y += Resources.fonts["04b03m"].LineSpacing;
                        sb.DrawString(Resources.fonts["04b03m"], word, new Vector2(205, pos.Y), Color.White);
                    } else {
                        sb.DrawString(Resources.fonts["04b03m"], word, new Vector2(Math.Max(pos.X - Resources.fonts["04b03m"].MeasureString(word).X, 205), pos.Y), Color.White);
                        pos.X += space;
                    }
                }
            }
开发者ID:sctjkc01,项目名称:Clocked,代码行数:18,代码来源:Convo.cs

示例15: DrawStringShadowed

	private static void DrawStringShadowed(SpriteBatch sb, SpriteFont font, string text, Vector2 pos, Color color, Color colorShadow, Vector2 origin = default(Vector2), float scale = 1f, SpriteEffects effects = SpriteEffects.None) {
		foreach (Vector2 vecOff in shadowOffset) sb.DrawString(font,text,new Vector2(pos.X+vecOff.X,pos.Y+vecOff.Y),colorShadow,0f,origin,scale,effects,0f);
		sb.DrawString(font,text,pos,color,0f,origin,scale,effects,0f);
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:4,代码来源:OSIBossHPBar.cs


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