This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction)pressPlayPause:(UIButton *)sender { | |
if (playing) { | |
playing = NO; | |
[self.playPauseButton setTitle:@"Play" forState:UIControlStateNormal]; | |
self.resetButton.hidden = NO; | |
} else { | |
[self.playPauseButton setTitle:@"Pause" forState:UIControlStateNormal]; | |
playing = YES; | |
self.resetButton.hidden = YES; | |
[self resetGame]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)updateLabels | |
{ | |
self.highScoreLabel.text = | |
[NSString stringWithFormat:@"High Score: %d",highScore]; | |
self.scoreLabel.text = | |
[NSString stringWithFormat:@"Score: %d",score]; | |
self.livesLabel.text = | |
[NSString stringWithFormat:@"Lives: %d",lives]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)countDown | |
{ | |
if (playing) { | |
timeLeft --; | |
if (timeLeft == 0) { | |
[self endGame]; | |
} | |
} | |
[self updateLabels]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)resetGame | |
{ | |
score = 0; | |
lives = 3; | |
timeLeft = 30; | |
} |
NewerOlder