Curve animation

Discussion in 'iOS Programming' started by blackmesa, Apr 6, 2009.

  1. macrumors newbie

    Joined:
    Mar 30, 2009
    #1
    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
     
  2. macrumors member

    Joined:
    Jul 28, 2008
    #2
    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 ;)
     
  3. macrumors member

    Joined:
    Apr 9, 2008
    #3
    You can do it by creating a CGMutablePathRef, and assigning it to your CAKeyframeAnimation instance.
     
  4. thread starter macrumors newbie

    Joined:
    Mar 30, 2009

Share This Page