views:

25

answers:

0

hello i have series of balls (12 balls) and i want to move them on the ellipse path when i touch them view layer and move to right or to left.

i tried to use CAKeyframeAnimation class with single object of them. this object moves correctly in the ellipse path (i used CGPathAddCurveToPoint to define the path), but this object moves in the specified duration to the end of the path, i want to move it dependent to my touch move in the part of the path not on the all the path.

and also what to do with the other objects? how to put them in series train after the first object?

this is part of the code:

CGMutablePathRef path = CGPathCreateMutable();

    CGPathMoveToPoint(path,NULL,276.0, 237.0);
    CGPathAddCurveToPoint(path,NULL,274.0,300.0,

                          74.0, 300.0,

                          46.0, 233.0);




    CGPathAddCurveToPoint(path,NULL,47.0,170.0,

                          274.0, 170.0,

                          274.0, 231.0);

CAKeyframeAnimation* animation = [CAKeyframeAnimation animation];
animation.path = thePath;
animation.duration = 2;  // two seconds
animation.repeatCount = 10000;  // "forever"
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

CAAnimation* pathAnimation = animation;
[flag1.layer addAnimation:pathAnimation forKey:@"position"];

thanks