views:

10

answers:

1

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;     



    }

   }
  }




 }                     

}
A: 

Sort of a sloppy answer, but in pseudo code:

-(IBAction)right {

if (playerCanMove==1) { //move player }

}

Set playerCanMove to 1 when the game loads, and set it to 0 on collision.

Andrew
Thank you......
Michael