Graphics Reference
In-Depth Information
}
@end
Figure 10.6 A bouncing ball animation implemented using keyframes
This approach works reasonably well, but it's cumbersome (calculating the keyframes and
keytimes is basically a matter of trial and error) and highly animation specific (if you
change any properties of the animation, you need to recalculate all the keyframes). What
would be really useful would be if we could write a method to convert any simple property
animation into a keyframe animation with an arbitrary easing function. Let's do that.
Automating the Process
In Listing 10.6, we split the animation into fairly large sections and used Core Animation's
ease-in and ease-out functions to approximate the curve we wanted. But if we split the
animation into smaller parts, then we can approximate any sort of curve just by using
straight lines (a.k.a linear easing). To automate this, we need to figure out how to do two
things:
Automatically split an arbitrary property animation into multiple keyframes
Represent our bounce animation as a mathematical function that we can use to offset
our frames
Search WWH ::




Custom Search