Cool, thanks. All I need to do now is the collision between the character and the blocks, and make a high score system.
So far the high scores, I have got this code in my main view controller:
Code:
-(void)viewDidLoad {
....
highscore_value = 0; }
-(void)moveBlocks {
...
if (character.center.y > 550) {
GameOverViewController *viewController = [[GameOverViewController alloc] initWithNibName:@"GameOverViewController" bundle:nil];
viewController.delegate = self;
[self presentModalViewController:viewController animated:YES];
[viewController release];
[self reset];
} }
-(void)reset {
self.gameState = kGameStatePaused;
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (score_value > highscore_value) {
[prefs setInteger:score_value forKey:@"highscore"];}
score_value = 0;
character.center = CGPointMake(180, 450);
//TODO: reset blocks
}
And this in my GameOverViewController:
Code:
- (void)viewDidLoad {
[super viewDidLoad];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSInteger highscore_value = [prefs integerForKey:@"highscore"];
highScore.text = [NSString stringWithFormat:@"%d", highscore_value]; }
Basically what I want is the score_value from my main view controller to be saved to NSUserDefaults as highscore_value if it is larger than the one already saved there, and then be shown in my GameOverViewController in the highscore label, but at the moment the highscore label updates to the highest score of the previous games, not the one that has just ended. Any advice?
Thanks,
Cam