I am wondering how to include debug code inside the XNA? Like console.writeline
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)
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.
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)
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);
}
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.
You can always use Debug.WriteLine
and read your Debug messages window. Or use the tracepoints.
© 2022 - 2024 — McMap. All rights reserved.