I have two UIImageViews named image1 and image2. What I want to do is: when image1 and image2 collide, image1 should grow larger( with a scale animation.) E.g. if image1 collides with image2 ten times , image1 should become 10 times bigger.
I try to use scale animation and CGRectIntersectsRect for the collision, then a timer for the collision but the image become larger just once time and and remains at that size after all subsequent collisions.
Here is my code :
-(void)collision {
if(CGRectIntersectsRect(imageView.frame,centre.frame)){
scale=scale+1;
imageView.alpha=0.5;
[imageView removeFromSuperview];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
centre.transform = CGAffineTransformScale(centre.transform, scale, scale);
[UIView commitAnimations];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(collision) userInfo:nil repeats:YES];
}
(TechZen says -- Author originally made a point that he is native French speaker and that his English is bit rough.)