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];
請將代碼粘貼在這裏...有很多方法可以完成動畫..不清楚您使用的是哪種方法 –
我已經添加了代碼。我正在使用塊動畫。 –