我有一个简单的动画运行,它以相机视图为背景上下移动。我试图以随机速率生成更多动画。这可能吗?
我正在通过UIView startAnimation运行我的动画。
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"enemyball.png"],
[UIImage imageNamed:@"playerball.png"]
, nil];
//animation of images
UIImageView *animatedView =[UIImageView alloc];
[animatedView initWithFrame:[self bounds]];
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:1];
[UIView setAnimationCurve:1];
[UIView setAnimationRepeatCount:INFINITY];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationBeginsFromCurrentState:YES];
CGAffineTransform transform = CGAffineTransformMakeTranslation(220, 330);
animatedView.transform = transform;
[UIView commitAnimations];
这是我想在相机视图中显示的叠加层。
- (void) viewDidAppear:(BOOL)animated {
enemyBall *overlay = [[enemyBall alloc] initWithFrame:CGRectMake(20, 20, 50, 50)];
//OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
// Create a new image picker instance:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// Set the image picker source:
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Hide the controls:
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
// Make camera view full screen:
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
// Insert the overlay:
//picker.cameraOverlayView = overlay;
picker.cameraOverlayView = overlay;
// Show the picker:
[self presentModalViewController:picker animated:YES];
[super viewDidAppear:YES];
}
我试图让我的动画以随机顺序和时间生成,但放置另一组数组代码似乎太多了,我不能有第二个叠加,因为它不会读取第二个叠加层。这可能吗?