1
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ So if my game has been running for 500 ms then this value will be equal to 0.5? \$\endgroup\$ – Masoud Darvishian Dec 28 '13 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 Dec 28 '13 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 Dec 28 '13 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.