我怎么有图像出现随机使用的NSTimer?

我有一个简单的动画运行,其上下移动用相机视图作为背景。 我想生成以随机速率更多的动画。 那可能吗?

我通过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]; }

我想有我的动画以随机顺序和时间生成,但将另一套数组代码似乎太多了,我不能有第二个覆盖,因为它不读取第二叠加。 这可能吗?

分类:iphone 时间:2015-03-15 人气:0
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 1.284 (s). 10 q(s)