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


C# SpriteBatch.DisableScissor方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:WoLfulus,项目名称:Almirante,代码行数:33,代码来源:Textbox.cs

示例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();
            }
        }
开发者ID:WoLfulus,项目名称:Almirante,代码行数:34,代码来源:Chat.cs


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