0

I just found something that caught my interest. See, I usually do my "timers" with an int Time = Duration; and in my update it would go Time -= gameTime.ElapsedGameTime.MilliSeconds;. However, I just tried to do it with gameTime.ElapsedGameTime.Seconds instead, since I thought it would be more performance-friendly. But now it isn't updating at all!

My code is basically:

Declaring variables: int Time = 120; SpriteFont spriteFont1;

Updating: Time -= gameTime.ElapsedGameTime.Seconds;

Drawing a string to tell me the time: spriteBatch.Draw(Time, Position, Color.White)

Somehow, the string only tells me that the time is decreasing when I'm doing it with MilliSeconds, not Seconds. Why?

4

1 回答 1

1

gameTime.ElapsedGameTime.Seconds是自上次更新以来的时间量。由于它更新非常快,因此更新之间的时间小于秒。Seconds 以 an 形式返回,int因此您将始终得到 0。

于 2013-06-13T19:58:50.617 回答