Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

To make a real-world example, lets assume I want to build an animated sprite for an explosion. The duration of the animation should last ~1 second, and we'll say exactly one second to make the math a bit more simple. And lets assume I'm using XNA and my goal is to target both XBox (60fps), PC (60fps), and Windows Phone 7 (30fps).

My question is this, how should I build the sprite animations so that my programming is as simple as possible without simply using a timer to calculate which frame I should be on (which I feel would make the animation "choppy")?

share|improve this question
    
What's wrong with using a timer? –  user744 Jan 19 '11 at 21:07
    
Why do you think a timer would make it choppy? –  user744 Jan 19 '11 at 21:08
    
On the lower framerate, if I'm skipping frames to keep up, it will be choppy... maybe it will still be acceptable? –  Nate Jan 19 '11 at 21:15
4  
You have two basic options, animate by frame or animate by time. If you animate by frame it will run twice as long. If you animate by time it will skip half the frames. Choppiness in this case is largely the result of bad animation (no blur, no squash+stretch, no ease-in/out); 30fps is more than smooth enough for sprites in motion. –  user744 Jan 19 '11 at 21:25
    
Of course it's going to be more choppy on the phone. There are less frames! It's acceptable for graphics to be more choppy on a phone, it's not a crazy powered behemoth or anything. –  Michael Coleman Jan 19 '11 at 21:29

1 Answer 1

up vote 6 down vote accepted

You have two basic options, animate by frame or animate by time. If you animate by frame it will run twice as long. If you animate by time it will skip half the frames. Choppiness in this case is largely the result of bad animation (no blur, no squash+stretch, no ease-in/out); 30fps is more than smooth enough for sprites in motion.

As for how I'd do it with a timer,

# Figure out how long the animation's been going
elapsed = (now - start)
# Figure out how far we are into it.
percentage = elapsed / animation.duration 
# Figure out what frame we are given that state.
frame = animation.frames[percentage * animation.frames.size()]
share|improve this answer
    
Excellent, thanks for including the bit about how you would go about implementing it. –  Nate Jan 20 '11 at 3:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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