0
問題是玩家與blackB碰撞時玩家不會停下來。它慢慢地穿過blackB。 IBAction正在與遊戲循環一起使用。我需要一種方式來徹底凍結玩家與blackB相撞時的狀態。歡迎任何幫助,我是一名初學者程序員。謝謝!iPhone - CGPointIntersectsRect碰撞問題?
播放機和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;
}
}
}
}
}