问题是当玩家与 blackB 碰撞时,玩家不会停下来。它缓慢地继续穿过黑色B。IBAction 与游戏循环一起使用。我需要一种在播放器与 blackB 碰撞时完全冻结播放器的方法。欢迎任何帮助,我是初学者程序员。谢谢!
player 和 blackB 都是 UIImageViews
- (IBAction)right
{
direction = kright;
if (direction == kright)
{
rightMovement = CGPointMake(kMovement,0);
blockVelocity.x += rightMovement.x;
player.center = CGPointMake(player.center.x + blockVelocity.x,player.center.y);
if(CGRectIntersectsRect(player.frame, blackB.frame))
{
if(player.center.x < blackB.center.x)
{
if(blockVelocity.x > 0)
{blockVelocity.x = zero;
}
}
}
}
}