2011-11-19 89 views
0

我能够在线性路径中进行动画制作。我如何让他们编程以随机路径移动?我阅读开发人员的“移动我”示例代码,但它不够清楚。那里有其他的动画教程吗?iPhone:为动画生成随机路径

//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]; 
+0

请将代码粘贴在这里...有很多方法可以完成动画..不清楚您使用的是哪种方法 –

+0

我已经添加了代码。我正在使用块动画。 –

回答

0

我不知道你是在问动画技术还是你只是在问随机散步。如果后者,wiki page是一个好的开始。