Displaying Life and Score

What fun would Whack-a-Cac be with no penalties for missing and no way to keep track of how well you are doing? Displaying the user’s score and life are crucial game-play elements in our sample game, and both methods have been called from methods that have been looked at earlier in this section.

Turn your focus now to displayNewScore: in IFCGameViewController.m. Anytime the score is updated, a call to displayNewScore: is necessary to update the score display in the game. In addition to displaying the score, every time the score reaches a multiple of 10 while less than or equal to 50, a new cactus is spawned. This new cactus spawning has the effect of increasing the difficulty of the game as the player progresses.

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.