本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.ToVector2方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.ToVector2方法的具体用法?C# Rectangle.ToVector2怎么用?C# Rectangle.ToVector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.ToVector2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: YnEntity
/// <summary>
/// Create a new <see cref="Yna.Engine.Graphics.YnEntity"/> with a procedural texture.
/// </summary>
/// <param name='rectangle'>Rectangle of the texture</param>
/// <param name='color'>Color of the texture</param>
public YnEntity(Rectangle rectangle, Color color)
: this()
{
_rectangle = rectangle;
_position = rectangle.ToVector2();
_texture = YnGraphics.CreateTexture(color, rectangle.Width, rectangle.Height);
_assetLoaded = true;
}
示例2: DrawText
public void DrawText(string text, Rectangle size, Color tint, float scale)
{
var textSize = GetSpriteFontByName("minecraft").MeasureString(text) * scale;
if (tint == null)
tint = Color.White;
Vector2 origin;
if (scale > 1f)
{
origin = textSize / 128;
Console.WriteLine($"TextSize: " + textSize.ToString());
Console.WriteLine("Origin: " + origin.ToString());
}
else
origin = Vector2.Zero;
Vector2 offsetPos = new Vector2(size.X + 2, size.Y + 2); //offset used for shadow
spriteBatch.DrawString(GetSpriteFontByName("minecraft"), text, offsetPos, Color.Black, 0, origin, scale, SpriteEffects.None, 0f);
spriteBatch.DrawString(GetSpriteFontByName("minecraft"), text, size.ToVector2(), tint, 0, origin, scale, SpriteEffects.None, 0f);
}