我对编程非常陌生,特别是创建 GUI;我以前只用 C# 编写过控制台程序,现在正尝试用 XNA 构建游戏。任何人都可以通过让我知道如何在 GUI 中打印到屏幕来帮助我吗?我目前正在尝试 的变体System.Console.WriteLine("");
,但不会打印到屏幕上。我正在使用的代码如下。谁能告诉我哪里出错了?
ResourceCounter.cs
:
public ResourceCounter(Vector2 pos, GameTime gameTime)`
{
position = pos;
over = false;
clicked = false;
gameTime = new GameTime();`
currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
System.Console.WriteLine("Resources: ", pSourceCount);
if (currentTime >= countDuration)
{
pSourceCount++;
**System.Console.WriteLine("Resources: ", pSourceCount);**
}
if (pSourceCount >= limit)
{
pSourceCount = 0;//Reset the counter;
}
}
在我的主要GameScreen.cs
课程中:
public override void Update(GameTime gameTime)
{
MouseState mState = Mouse.GetState();
menu.Update(mState, cursor, gameTime);
if (menu.currentstate == State.campaign)
{
campaign.Update(pTower);
//campaign.Update(eTower);
**System.Console.WriteLine("Resources: ", pSourceCount);**
}
base.Update(gameTime);
}