UIAlertView Popping Up A Bunch Of Times In The if(CGRectIntersectsRect) Code ?
Hey guys when I am using the. if CGRectIntersectsRect(image5.frame,image2.frame)) in my Xcode project. I have an UIAlertView right in the code. At times my app will start making the alert pop up over and over again and sometimes it works. Its when two images touch its suppose to have this code come up. I have it formatted like this. I also have a -(void)checkCollision in there. See any errors please help me. Here you go:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"You Lose" message:[NSString stringWithFormat:@"The Nail hit you and you popped. You were alive for %d seconds. Keep playing and see if you can beat that!", mainInt] delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alertView show];
[alertView release];
[randomMain invalidate];
randomMain = nil;
How often is your check collision method being called? If you have a timer that checks it every second or so, the object colliding with the other object could still be intersecting, therefore, the method gets called multiple times
How often is your check collision method being called? If you have a timer that checks it every second or so, the object colliding with the other object could still be intersecting, therefore, the method gets called multiple times
every 0.05 seconds it calls the method to move the nails, and everytime the nail method is called so is the collision check