清除XNA 4.0中绘制的SpriteFont

发布于 2024-12-27 06:46:28 字数 279 浏览 2 评论 0原文

该代码主要用于显示用户触摸屏幕的次数。但问题是每次更新方法(XNA 4.0)都会绘制之前的纹理,因此无法读取计数。每次重绘时如何清除 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);

This code is used to basically display number of times the user touches the screen. But the problem is every time the Update method(XNA 4.0), the previous texture is Drawn upon , therefore the count cannot be read. How do i clear the SpriteFont texture each time when it is redrawn?.

//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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

删除会话 2025-01-03 06:46:28

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

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

Make sure to clear the screen at the beginning of Draw()

GraphicsDevice.Clear(Color.Black); //Use any color of your choice
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文