2
我试图在两个图像触摸动作时发生。从我所看到的CGRecIntersectRect中完成此操作的最佳方式是,当它使用动画循环中的图像时,它的工作效果非常好。如果任何人都可以帮我弄清楚,那么当这两个图像触摸动作发生时,会惊人! `动画过程中的图像碰撞
- (无效)startanimation {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:2];
[UIView setAnimationDidStopSelector:@selector(animationdidstop) ];
_enemy1.center = CGPointMake(_enemy1.center.x +390, _enemy1.center.y);
[UIView commitAnimations];
}
-(void)animationdidstop
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:2];
[UIView setAnimationDidStopSelector:@selector(startanimation) ];
_enemy1.center = CGPointMake(_enemy1.center.x -390, _enemy1.center.y);
[UIView commitAnimations];
}
-(void)collision
{
if (CGRectIntersectsRect(_node.frame, _bounds1.frame)) {
NSLog(@"got to collision");
[_node setHidden:YES];
}
}
`
这部分后立即来了,是哪里的问题。 _enemy1.frame似乎没有认识到它的相互碰撞,或者我不确定问题到底是什么,但这是我认为问题所在。
-(void)collision
{
if (CGRectIntersectsRect(_node.frame, _enemy1.frame)) {
NSLog(@"got to collision");
[_node setHidden:YES];
}
}
}
CGRectIntersectRect为什么不工作? – huddie96
如何以及何时调用' - (void)collision'方法? – RaffAl