Is there a way to use something like Console.write to debug XNA code?

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

+6
source share
5 answers

Have you seen the Debug class in the System.Diagnostics namespace? This can send output to the debug console in VS (or external, such as DebugView).

+3
source

Turn on the console.

In Visual Studio, right-click your project in Solution Explorer. Then click Properties, and on the Application tab, select Console Application as the output type.

Remember to change it to “Windows Application” to disable the console when you finish debugging.

+6
source

There is a spritebatch.DrawString (....) method for drawing text, this is how I draw the number of frames per second.

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); } 
+1
source

Perhaps you should take a look at our Gearset toolkit . This is a set of tools that can help you with this. It has a special window that shows you a beautiful view of the result, organized by color, and provides filtering, which can be very useful when there is a lot of output.

Gearset also provides you with other tools, such as editing a curve and checking objects in real time. There is a free version and a paid version (the difference is the only feature not available in the free version). Hope this helps.

+1
source

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

0
source

Source: https://habr.com/ru/post/907645/


All Articles