Hi everyone, I'm French, so excuse me for my English. My problem is this: I have an image in the center of the screen called viewToRotate, then I have an image called flakeView that is created off-screen and then it moves to the center, and every second the timer does this (create a flakeView off-screen, and then move it to the center of the screen).
What I wanted to do was: if flakeView and viewToRotate collide, reduce the view alpha of viewToRotate to 0.5. But when flakeView appears on the screen, the alpha reduction action is called without collision viewToRotate and flakeView, so they collide before they touch. I do not know why. How can i solve this. Here is the code:
UIImageView* flakeView = [[[UIImageView alloc] initWithImage:flakeImage] autorelease];
int startY = round(random() % 320);
flakeView.center = CGPointMake(490, startY);
flakeView.alpha = 1;
[self.view addSubview:flakeView];
[UIView animateWithDuration:7
animations:^{
flakeView.center = viewToRotate.center;
}];
}
-(void)checkCollision{
if(CGRectIntersectsRect(flakeView.frame, viewToRotate.frame) == 1)
{
viewToRotate.alpha=0.5;
}
}