The problem is when the player collides with the blackB the player doesn't stop. It slowly continues through the blackB. The IBAction is being used with a game loop. I need a way to freeze the player completely when it collides with the blackB. Any help is welcome, I am a beginner programmer. Thank you!
player and blackB are both 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;
}
}
}
}
}