PDA

View Full Version : Curve animation




blackmesa
Apr 6, 2009, 09:39 AM
Is it possible to move an image in animation ([UIView beginAnimation] block) on a curve?

Let's say I have an image located at x1,y1. I want that image to move to x2,y2 following the equation:
a*x^2+b*x*y+c*y^2+d*x+e*y+r=0



Taum
Apr 6, 2009, 12:07 PM
I'm pretty positive it could be done by creating a CABasicAnimation and tweaking either the valueFunction (from the CAPropertyAnimation superclass) or the timingFunction (from the CAAnimation superclass).

However I think you would have to make your equation a function of the time, but that is probably just basic math that I'm too busy/lazy to think about at the moment ;)

CarlosH
Apr 7, 2009, 02:07 PM
Is it possible to move an image in animation ([UIView beginAnimation] block) on a curve?

Let's say I have an image located at x1,y1. I want that image to move to x2,y2 following the equation:
a*x^2+b*x*y+c*y^2+d*x+e*y+r=0

You can do it by creating a CGMutablePathRef, and assigning it to your CAKeyframeAnimation instance.

blackmesa
Apr 8, 2009, 05:55 AM
10x guys