[quote]I don’t understand exactly what you guys are saying when you mention time based and frame based animation. What is the difference exactly?
[/quote]
With time based movement, the speed at which everything animates depends on how long the last frame took. This ensures that everything moves at the same speed, independently of the frame rate. Works great for 3D games, but sucks for 2D (especially scrolling games).
With tick based movement, the speed at which everything animates is fixed, so the speed of the movement depends on the framerate. If the frame rate drops, the game gets slower. So you need to ensure that your game logic updates at a constant rate, which may require the game to occasionally drop rendered frames if the target frame rate is not achieved.
If you throttle a time based game loop to a fixed, constant frame rate, it will basically behave the same as tick based movement (if the target frame rate is always achieved).
So what you’re doing is basically tick (or frame) based movement.
[quote]However an easier method than my previous code would be simply to record tha animation start time on a variable and then compute the anim frame i need to use to render based on the formula ((current time - start time) % fps) if it is a looping animation. No frame behind issues this way.
[/quote]
This looks more like time based animation, but it doesn’t take movement of your game objects in account.
Maybe I’m just doing it wrong or maybe there’s an error in my thinking, but when I implement time based movement, I have a method in all game objects like this:
public void update(float deltaTime) {... }
Where deltaTime is the time which the last frame took to complete, which is used to scale the movement. So the next frame’s animation might be off, if the current frame will take a drastically different amount of time to complete, because the current frame update is based on the time from the previous frame update, which was already displayed.