我试图让'luke'跳过一个对象来确保游戏不会结束,他会这样做,但即使他避免了游戏仍然结束的对象,就好像luke还没有离开他在动画期间的原始位置。Collision detection&animateWithDuration
我在-(void)touchesBegin
中使用了UIView animateWithDuration来试图实现这一点。
[UIView animateWithDuration:3
animations:^
{
luke.center = CGPointMake(luke.center.x +0, luke.center.y -60);
}
completion:^(BOOL completed)
{
if (completed)
{
[UIView animateWithDuration:3
animations:^
{
luke.center = CGPointMake(luke.center.x +0, luke.center.y +60);
}];
}
我也使用CGRectIntersectsRect
告诉我,当两个物体发生碰撞
-(void)collision {
if (CGRectIntersectsRect(luke.frame, smallboulder.frame)) {
[self endgame];
}
if (CGRectIntersectsRect(luke.frame, largeboulder.frame)) {
[self endgame];
}
if (CGRectIntersectsRect(luke.frame, cactus.frame)) {
[self endgame];
}
终于我可以使用动画设置为NSArray
跳时表现出的运动。
非常感谢
JP
为什么你使用这种过时的Xcode版本? –
我正在使用一个macbook4.1,我不能升级雪豹以上。因此过时的版本 – user3369583
你有更现代的PC吗?您可以将小牛安装在虚拟机中并开展工作。 –