I am using a UIView
animation to move a button across the screen. While it is moving, I have an NSTimer
running the method
checkForCollision
which looks like this:
for(UIButton* b in squares)
if(CGRectIntersectsRect(playerSquare.frame, b.frame)) {
[self showEndMenu];
break;
}
with an interval of .05; I would like for that method to notify me any time the button moves across the path of another. The problem, it appears, is that when it checks for the frame of the UIButton b
, it only sees the frame towards which the button is moving.
I have the button being animated like this:
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:1.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
view.center = destPoint;
[UIView commitAnimations];
So, if the destPoint intersects the CGRect
playerSquare.frame
, [self showEndMenu]
is called. But if the frame / position at which the button is, say, halfway through the animation, intersects playerSquare
, [self showEndMenu]
doesn't get called. I don't know how to solve this; I can provide more code if need be. Thank you!