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\$

1 Answer 1

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.

\$\endgroup\$
3
  • \$\begingroup\$ So if my game has been running for 500 ms then this value will be equal to 0.5? \$\endgroup\$ Commented 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\$ Commented 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
    Commented Dec 28, 2013 at 16:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .