PDA

View Full Version : Animation - Stopping image at 'pos' position




Moon013
Sep 3, 2008, 02:39 AM
i uses core animation. I uses this to make it animate from a place to the other:

CABasicAnimation *animation;

animation = [CABasicAnimation animationWithKeyPath:@"position"];

animation.duration = duration;
animation.repeatCount = 1;
animation.fromValue = [NSValue valueWithCGPoint:from];
animation.toValue = [NSValue valueWithCGPoint:to];

what I want to do is when i touch an image while its animating, the image will stop at the center, and animation stops.

The problems faced are:
- How do I touch an image while its animation? the image x, y position does not change while its animating? it is based on what you put it when you alloc the image?

- how do i make it stop and put it at the center? Using transfrom to transform the image from its original position to the center of the screen?

Any help appreciated. Kind of noob here.

Chris