我正在使用UIView
动画在屏幕上移动按钮。当它移动时,我有一个NSTimer
正在运行的方法
checkForCollision
看起来像这样:
for(UIButton* b in squares)
if(CGRectIntersectsRect(playerSquare.frame, b.frame)) {
[self showEndMenu];
break;
}
间隔为 0.05;我希望该方法在按钮移动到另一个路径时通知我。问题似乎在于,当它检查 的框架时UIButton b
,它只看到按钮正在移动的框架。
我有这样的动画按钮:
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:1.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
view.center = destPoint;
[UIView commitAnimations];
因此,如果 destPoint 与 相交CGRect
playerSquare.frame
,[self showEndMenu]
则调用。但是,如果按钮所在的帧/位置,例如,动画进行到一半, intersectsplayerSquare
就[self showEndMenu]
不会被调用。我不知道如何解决这个问题;如果需要,我可以提供更多代码。谢谢!