【问题标题】:Clearing the drawn SpriteFont in XNA 4.0在 XNA 4.0 中清除绘制的 SpriteFont
【发布时间】:2012-01-16 23:26:36
【问题描述】:

此代码基本上用于显示用户触摸屏幕的次数。但问题是每次更新方法(XNA 4.0)时,之前的纹理都是 Drawn on ,因此无法读取计数。每次重绘时如何清除 SpriteFont 纹理?

//Code used to draw the Sprite Font.!
batch.DrawString(fontSegoe, "Touches "+count, new Vector2(100, 100), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);

【问题讨论】:

  • 如果您要绘制到 RenderTarget2D 并且其 RenderTargetUsage 设置为 PreserveContents,您可以将其绘制到另一个 RenderTarget 或更改其设置。

标签: windows-phone-7 xna sprite windows-phone-7.1 spritefont


【解决方案1】:

确保在 Draw() 开始时清除屏幕

GraphicsDevice.Clear(Color.Black); //Use any color of your choice

【讨论】:

  • OP 注意:这是你清除任何东西的方式,而不仅仅是 Sprites/SpriteFonts。
猜你喜欢
  • 1970-01-01
  • 2012-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多