There are only two important methods left to review to tie this all together. First is the update
method. Let's look at the applicable portions of the update
method (we have left placeholders for the other portions of the
update
method, but those will not be addressed here. Please refer the code bundle for this book to see those details):
-(void)update:(ccTime)dt { for (MXMoleHill *aHill in moleHillsInPlay) { if (aHill.hillMole.moleState == kMoleHit) { [[aHill hillMole] setMoleState:kMoleMoving]; [self scoreMole:[aHill hillMole]]; } } if (molesInPlay < maxMoles && spawnRest > 10) { [self spawnMole:self]; spawnRest = 0; } else { spawnRest++; } // Update the timer value & display // Protection against overfilling the timer // Update the timer visual // Game Over / Time's Up }
On every loop of the update
method, we iterate...