Let the image object move according the slot we have generated is a common feature in the game.But we should get this feature in the non-game app.So how to do it?
So follow me...
- Generate the path you want like this:
CGMutablePathRef path = CGPathCreateMutable();
-Then move to the start point you want:
CGPathMoveToPoint(path, NULL, startPoint.x, startPoint.y);
the startPoint is your first point.
- Add all the point data to path
CGPathAddLineToPoint(path, NULL, tempPoint.x, tempPoint.y);
- Make object moving
[self.layer addAnimation:[self animation: path] forKey:@"position"];
self.layer.needsDisplayOnBoundsChange = YES;
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
path is the path you have made.
More information you can look this demo:
http://www.cocoachina.com/bbs/read.php?tid=11425&keyword=%C2%B7%BE%B6%7C%B6%AF%BB%AD%3C/p%3E
But you should modify the code to meet your requirement.
Thanks,
Blues