Is there a way to use something like Console.write to debug in XNA code?
Asked Answered
S

5

7

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

Subtraction answered 4/2, 2012 at 13:59 Comment(0)
S
3

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)

Superficies answered 4/2, 2012 at 14:5 Comment(0)
S
6

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.

Serf answered 4/2, 2012 at 14:3 Comment(0)
S
3

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)

Superficies answered 4/2, 2012 at 14:5 Comment(0)
S
1

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);
        }
Stefanysteffane answered 6/2, 2012 at 3:9 Comment(0)
B
1

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.

Bogeyman answered 4/4, 2012 at 14:3 Comment(0)
G
0

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

Gorse answered 4/2, 2012 at 14:4 Comment(1)
You can select it from the combobox in the Output window tab (if I remember correctly, the output window selects the debug mode when you run your app in debug mode).Gorse

© 2022 - 2024 — McMap. All rights reserved.