I was wondering what is exactly the value of gameTime.ElapsedGameTime.TotalSeconds in a second? Please explain it to me completely and as great as you can.
1 Answer
\$\begingroup\$ \$\endgroup\$
3 From the documentation ElapsedGameTime is:
Property Value
Elapsed game time since the last update.
This means it's the amount of time since the last time the update function was called. It's a TimeSpan. Getting TotalSeconds from a TimeSpan will give you the time in seconds. This is likely to be a pretty small value, since updates happen very fast.
- \$\begingroup\$ So if my game has been running for 500 ms then this value will be equal to 0.5? \$\endgroup\$Masoud Darvishian– Masoud Darvishian2013-12-28 08:13:09 +00:00Commented Dec 28, 2013 at 8:13
- 1\$\begingroup\$ No, the update method is called many times in 500ms. If the game is running at 60 frames per second the value is likely to be 1 / 60 = 0.0166 seconds. \$\endgroup\$craftworkgames– craftworkgames2013-12-28 10:30:05 +00:00Commented Dec 28, 2013 at 10:30
- \$\begingroup\$ @MesutDarvishian If you are looking for that time interval that passed since the last frame, you really should just use
1./60.(fix your timestep) \$\endgroup\$bobobobo– bobobobo2013-12-28 16:00:26 +00:00Commented Dec 28, 2013 at 16:00