3
\$\begingroup\$

2D sprite Animation is supposed to be based on the elapsed time from the previous update so that it runs (and looks the same) no matter the speed of the machine/device it's running on.

The method that moves my game objects already takes into account the elapsed time. The distance the object moves during updates is the elapsed time (delta) * the objects velocity.

Because the object's location changes based on the elapsed time, would it look (/run the same on all machines) passing the "distance delta" to my Animation update method instead of the delta time? The distance delta would be a number of pixels. Using the distance would ensure my frame animation lines up with how far the object has traveled.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Yeah that would work. Commonly when a game wants to have the animation and location synchronized like this, they will have a fixed time delta that is passed to both their simulation (what moves the object) as well as the animation system. Your idea would also work though (:

\$\endgroup\$
1
  • \$\begingroup\$ OK, I figured it would work since the Animation class would be the exact same no matter if it was a long time or distance. Thanks. \$\endgroup\$ Apr 12, 2015 at 15:08

You must log in to answer this question.

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