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

| improve this answer | |
\$\endgroup\$
  • \$\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\$ – SmokeyTehBear Apr 12 '15 at 15:08

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.