本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.Subtract方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Subtract方法的具体用法?C# Rectangle.Subtract怎么用?C# Rectangle.Subtract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Subtract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCreatureBars
public void DrawCreatureBars(SpriteBatch Batch, ClientCreature Creature, Vector2 Offset)
{
if (Creature.Name != "")
{
GameSprite Sprite = GameData.GetCreatureSprite(Creature.Outfit.LookType);
Vector2 TextSize = UIContext.StandardFont.MeasureString(Creature.Name);
Color LifeColor = LifeColorForCreature(Creature);
// Put at the center of the sprite
Offset.X += Sprite.Width * 16;
Offset.Y -= Sprite.Height * 16;
// Render offsets are negative
Offset.X += Sprite.RenderOffset;
Offset.Y += Sprite.RenderOffset;
// Render the text
Vector2 TextOffset = Offset;
// Move it above the health bar
TextOffset.X = (int)(TextOffset.X - TextSize.X / 2);
TextOffset.Y -= 16;
DrawBoldedText(Batch, Creature.Name, TextOffset, false, LifeColor);
//
Rectangle BlackBar = new Rectangle(
(int)(Offset.X - 14),
(int)Offset.Y,
28, 4
);
UIContext.Skin.DrawBorderedRectangle(Batch, BlackBar, Color.Black);
Rectangle InsideBar = BlackBar.Subtract(new Margin(1));
if (Creature.MaxHealth > 0)
InsideBar.Width = InsideBar.Width * Creature.Health / Creature.MaxHealth;
UIContext.Skin.DrawBorderedRectangle(Batch, InsideBar, LifeColor);
}
}