1

Just a quick issue when my app reloads two images collide without actually touching. I have reset the frames of these images to their original positioning i did as follows:

-(void)viewWillAppear:(BOOL)animated {

redball.frame = CGRectMake(redballpos.x, redballpos.y, redball.frame.size.width, redball.frame.size.height); //makes frame
ball1.frame = CGRectMake(ball1pos.x, ball1pos.y, ball1.frame.size.width, ball1.frame.size.height);
ball2.frame = CGRectMake(ball2pos.x, ball2pos.y, ball2.frame.size.width, ball2.frame.size.height);


}

and my original ViewDidload is as follows:

- (void)viewDidLoad
{

redballpos = redball.frame.origin;
ball1pos = ball1.frame.origin;
ball2pos = ball2.frame.origin;
exit.hidden = YES;
ball2.hidden = YES;
highScore = [[NSUserDefaults standardUserDefaults] integerForKey:@"HighScoreSaved"];
adView.delegate = self;


[super viewDidLoad];

}

Would anyone know what i am doing wrong? All advice would be much appreciated

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
Ray
  • 11
  • 4
  • For one, You should call the [super viewDidLoad]; before anything else. Second, there is no [super viewWillAppear:animated] in your code. Last but not least for collision detection between rects you could probably use the CGRectIntersectsRect function? – Totumus Maximus Apr 01 '14 at 07:05
  • Check this one: http://stackoverflow.com/questions/345838/ball-to-ball-collision-detection-and-handling?rq=1 – Dhaval Bhadania Apr 01 '14 at 08:49
  • I see. Its just its almost like the game vc does not reload when the game ends. What is the best way to refresh a Vc when a game ends? – Ray Apr 01 '14 at 10:35
  • http://iphonedevsdk.com/forum/iphone-sdk-development/102221-reset-a-uiviewcontroller-to-its-initial-view.html – Anoop Vaidya Apr 04 '14 at 11:29
  • For more audience and reach always use proper tags!!! – Anoop Vaidya Apr 04 '14 at 11:30

0 Answers0