我可以在线性路径中播放动画。如何让它们编程以随机路径移动?我读过开发人员的“移动我”示例代码,但不够清楚。是否还有其他动画,如这些动画?
//Loading the array with images
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"enemyball.png"],
[UIImage imageNamed:@"playerball.png"]
, nil];
//animation of images
UIImageView *animatedView =[[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 50.0, 50.0)];
animatedView.animationImages = myImages;
animatedView.animationDuration = 0.25; // seconds
animatedView.animationRepeatCount = 0; //0 loops for ever/noted
[animatedView startAnimating];
[self addSubview:animatedView];
//animation movement
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationRepeatCount:INFINITY];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationBeginsFromCurrentState:YES];
CGAffineTransform transform = CGAffineTransformMakeTranslation(100, 0);
animatedView.transform = transform;
[UIView commitAnimations];