本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.DisableScissor方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DisableScissor方法的具体用法?C# SpriteBatch.DisableScissor怎么用?C# SpriteBatch.DisableScissor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.DisableScissor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDraw
/// <summary>
/// Called when drawing the HUD component.
/// </summary>
/// <param name="batch">The sprite batch instance.</param>
/// <param name="position"></param>
protected override void OnDraw(SpriteBatch batch, Vector2 position)
{
if (this.Visible)
{
// Background
batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)this.Size.X, (int)this.Size.Y), this.color);
// Borders
batch.DrawLine(position, position + new Vector2(this.Size.X, 0), Color.Black, 2);
batch.DrawLine(position + new Vector2(this.Size.X, 0), position + new Vector2(this.Size.X, this.Size.Y), Color.Black, 2);
batch.DrawLine(position + new Vector2(this.Size.X, this.Size.Y), position + new Vector2(0, this.Size.Y), Color.Black, 2);
batch.DrawLine(position + new Vector2(0, this.Size.Y), position, Color.Black, 2);
batch.EnableScissor(new Rectangle((int)position.X + 2, (int)position.Y + 2, (int)this.Size.X - 4, (int)this.Size.Y - 4));
{
var text = this.Password ? (this.Text.Length > 0 ? Enumerable.Repeat("*", this.Text.Length).Aggregate((s, n) => s + n) : "") : this.Text;
var size = this.font.Content.MeasureString(this.Text);
var pos = position + new Vector2(5, (this.Size.Y - size.Y) / 2);
if (size.X > this.Size.X - 10)
{
pos.X = (pos.X + this.Size.X - 10) - size.X;
}
batch.DrawString(this.font.Content, text, pos, Color.Black);
}
batch.DisableScissor();
}
}
示例2: OnDraw
/// <summary>
/// Draw
/// </summary>
/// <param name="batch"></param>
/// <param name="position"></param>
protected override void OnDraw(SpriteBatch batch, Vector2 position)
{
if (this.Visible)
{
// Background
batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)this.Size.X, (int)this.Size.Y), this.color);
// Borders
batch.DrawLine(position, position + new Vector2(this.Size.X, 0), Color.Black, 2);
batch.DrawLine(position + new Vector2(this.Size.X, 0), position + new Vector2(this.Size.X, this.Size.Y), Color.Black, 2);
batch.DrawLine(position + new Vector2(this.Size.X, this.Size.Y), position + new Vector2(0, this.Size.Y), Color.Black, 2);
batch.DrawLine(position + new Vector2(0, this.Size.Y), position, Color.Black, 2);
batch.EnableScissor(new Rectangle((int)position.X + 2, (int)position.Y + 2, (int)this.Size.X - 2, (int)this.Size.Y - 2));
{
batch.Draw(this.texture, new Rectangle(0, 0, 1, 1), Color.White * 0.0f);
var lastPosition = position + new Vector2(2, this.Size.Y - 2);
for (int i = this.messages.Count - 1; i >= 0; i--)
{
var text = this.messages[i];
var size = this.font.Content.MeasureText(text);
lastPosition.Y -= size.Y;
batch.DrawString(this.font.Content, text, lastPosition, Color.Black);
}
}
batch.DisableScissor();
}
}