有没有办法使用像 Console.write 这样的东西在 XNA 代码中进行调试?

发布于 2025-01-02 19:51:36 字数 48 浏览 7 评论 0原文

我想知道如何在 XNA 中包含调试代码?就像console.writeline一样

I am wondering how to include debug code inside the XNA? Like console.writeline

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

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

发布评论

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

评论(5

凉栀 2025-01-09 19:51:36

启用控制台。

在 Visual Studio 中,右键单击“解决方案资源管理器”中的项目。然后单击“属性”并在“应用程序”选项卡中选择“控制台应用程序”作为输出类型。

不要忘记将其更改回“Windows 应用程序”,以便在完成调试后禁用控制台。

Enable the console.

In Visual Studio right-click your project in Solution Explorer. Then click on "Properties" and in the "Application" tab select "Console Application" as your Output-Type.

Don't forget to change it back to "Windows Application" in order to disable the console when you are done debugging.

始终不够爱げ你 2025-01-09 19:51:36

您见过 System.Diagnostics 命名空间中的 Debug 类吗?可以将输出发送到 VS 中的调试控制台(或外部控制台,如 DebugView)

have you seen the Debug class in the System.Diagnostics namespace? That can send output to the debug console in VS (or an external one like DebugView)

喜爱纠缠 2025-01-09 19:51:36

对于绘制文本,有方法 spritebatch.DrawString(....) 这就是我绘制 fps 计数的方法。

     class FPS_Counter
     {
        private SpriteFont spriteFont;
        private float FPS = 0f;
        private float totalTime;
        private float displayFPS;

        public FPS_Counter(SpriteBatch batch, ContentManager content)
        {
            this.totalTime = 0f;
            this.displayFPS = 0f;
        }
        public void LoadContent(ContentManager content)
        {
            this.spriteFont = content.Load<SpriteFont>("Fonts/FPSSpriteFont");
        }
        public void DrawFpsCount(GameTime gTime,SpriteBatch batch)
        {

            float elapsed = (float)gTime.ElapsedGameTime.TotalMilliseconds;
            totalTime += elapsed;

            if (totalTime >= 1000)
            {
                displayFPS = FPS;
                FPS = 0;
                totalTime = 0;
            }
            FPS++;

            batch.DrawString(this.spriteFont, this.displayFPS.ToString() + " FPS", new Vector2(10f, 10f), Color.White);
        }

For drawing text there is method spritebatch.DrawString(....) this is how i draw fps count.

     class FPS_Counter
     {
        private SpriteFont spriteFont;
        private float FPS = 0f;
        private float totalTime;
        private float displayFPS;

        public FPS_Counter(SpriteBatch batch, ContentManager content)
        {
            this.totalTime = 0f;
            this.displayFPS = 0f;
        }
        public void LoadContent(ContentManager content)
        {
            this.spriteFont = content.Load<SpriteFont>("Fonts/FPSSpriteFont");
        }
        public void DrawFpsCount(GameTime gTime,SpriteBatch batch)
        {

            float elapsed = (float)gTime.ElapsedGameTime.TotalMilliseconds;
            totalTime += elapsed;

            if (totalTime >= 1000)
            {
                displayFPS = FPS;
                FPS = 0;
                totalTime = 0;
            }
            FPS++;

            batch.DrawString(this.spriteFont, this.displayFPS.ToString() + " FPS", new Vector2(10f, 10f), Color.White);
        }
梦亿 2025-01-09 19:51:36

您可能想看看我们的工具集 Gearset。这是一组可以帮助您实现这一目标的工具。它有一个专用窗口,可以向您显示按颜色组织的漂亮输出视图,并提供过滤功能,当有大量输出时,过滤功能会变得非常有用。

Gearset 还为您提供其他工具,例如曲线编辑和对象的实时检查。有免费版本和付费版本(区别在于免费版本不提供单个功能)。希望有帮助。

You might want to take a look at our toolset Gearset. It is a set of tools that can help you with that. It has a dedicated window that shows you a pretty view of the output, organized by color, and provides filtering which can become quite useful when there's a lot of output.

Gearset also provides you with other tools like curve editing and real-time inspection of your objects. There's a free version and a paid version (the difference being a single feature which is unavailable in the free version). Hope it helps.

画离情绘悲伤 2025-01-09 19:51:36

您始终可以使用 Debug.WriteLine 并读取调试消息窗口。或者使用跟踪点

You can always use Debug.WriteLine and read your Debug messages window. Or use the tracepoints.

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