Quote:
Originally Posted by wuuvoo
I am trying to get my animation move in more than one path. I have this set of codes but it's only moving in the first two generated coordinates. Anyone know what's wrong with the coding?
Code:
[UIView animateWithDuration:4
delay:0
options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse
animations:^{faceAni.transform = CGAffineTransformMakeTranslation(0, 480);}
completion:^(BOOL finished) {
[UIView animateWithDuration:4
delay:0
options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse
animations:^{faceAni.transform = CGAffineTransformMakeTranslation(-320, 0);}
completion:^(BOOL finished) {
[UIView animateWithDuration:4
delay:0
options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse
animations:^{faceAni.transform = CGAffineTransformMakeTranslation(-200, 0);}
completion:NULL];
}];
}];
|
Are you trying to move your faceAni view by the specified amount of pixels (Down by 400 pixels, then to the left 320 pixels, then to the left 200 pixels?)
If so, you're not doing it right. You're assigning a new transformation matrix rather than changing the existing transformation matrix.
Use code like this:
Code:
faceAni.transform = CGAffineTransformTranslate(faceAni.transform, 0, 480);
That code will apply the specified amount of change to it's existing transform (thus moving it by the amount you ask for.
Note that for simple movements, it's usually easier to change the center property:
Code:
faceAni.center = CGPointMake(faceAni.center.x, faceAni.center.y + 480);
That's especially true if your doing multiple changes at once, like shifting, rotating and scaling. By using changing the center property, you don't have to worry about translation affecting the results of the other changes to the transformation matrix.