From 93f26235d891b7558aaf8aa0353104cdec3609c9 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Wed, 17 Aug 2011 21:10:55 -0400 Subject: Fixed "Game Over" tutorial bubble related bugs Previously, Tutorial Mode decided whether to display the "Game Over" bubble in the setLives method, which is called before the FallingObjectDelegate methods. This caused two bugs: A) showing a tutorial bubble pauses the scheduler and the didMissItem method would under certain circumstances attempt to schedule a delayed action, causing the game to stop processing the tick and jump to showing the tutorial bubble without removing the falling object. When the tutorial bubble got dismissed, tick would be restarted and the player would lose another life. B) didDestroyItem under certain circumstances would attempt to show a tutorial bubble and if the "Game Over" tutorial bubble had already been set, it would be overwritten with the new tutorial bubble, resulting in the "Game Over" tutorial bubble never being shown. Both of these bugs have been fixed by moving the "Game Over" bubble code out of setLives and into didDestroyItem. Fixes #203, #205 --- Classes/TutorialMode.m | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/Classes/TutorialMode.m b/Classes/TutorialMode.m index ed51648..1ada34a 100644 --- a/Classes/TutorialMode.m +++ b/Classes/TutorialMode.m @@ -20,6 +20,7 @@ // 2002 - items that are dropped after you miss first dropped item to demonstrate what happens when you catch // 2003 - 1-Up // 2009 - rock +// 2010 - random item dropped after death from first rock @implementation TutorialMode @@ -121,11 +122,34 @@ { [self schedule:@selector(randomlyAddObject:) interval:2.5f]; } else if (item.sprite.tag == 2009) + { + if ((lives < 1) && (!showedDeathBubble)) + { + showedDeathBubble = YES; + + TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"You lost all your lives! Normally, you'd be taken to a game over screen where you could submit your score to the highscore list, but we're a bit more forgiving in tutorial mode." name:@"gameover-rock"]; + self.currentTutorial = bubble; + [bubble release]; + } else { + TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"As you play, Cart Collect gets progressively more intense. Watch what happens when rocks are added to the mix and the speed is turned up." name:@"intense"]; + self.currentTutorial = bubble; + [bubble release]; + } + } else if (item.sprite.tag == 2010) { TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"As you play, Cart Collect gets progressively more intense. Watch what happens when rocks are added to the mix and the speed is turned up." name:@"intense"]; self.currentTutorial = bubble; [bubble release]; } + + if ((lives < 1) && (!showedDeathBubble)) + { + showedDeathBubble = YES; + + TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"You lost all your lives! Normally, you'd be taken to a game over screen where you could submit your score to the highscore list, but we're a bit more forgiving in tutorial mode." name:@"gameover"]; + self.currentTutorial = bubble; + [bubble release]; + } } - (void)setCurrentTutorial:(TutorialBubble *)m_currentTutorial @@ -191,6 +215,13 @@ object.sprite.tag = 2003; [object release]; } delay:2.0f]; + } else if ([currentTutorial.name isEqual:@"gameover-rock"]) + { + [self scheduleDelayedAction:^{ + FallingObject* object = [self dropRandomItem]; + object.sprite.tag = 2010; + [object release]; + } delay:1.0f]; } else if ([currentTutorial.name isEqual:@"intense"]) { [self schedule:@selector(randomlyAddObject:) interval:1.0f]; @@ -252,20 +283,6 @@ return [self dropSpecificItem:object]; } -- (void)setLives:(int)m_lives -{ - [super setLives:m_lives]; - - if ((lives < 1) && (!showedDeathBubble)) - { - showedDeathBubble = YES; - - TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"You lost all your lives! Normally, you'd be taken to a game over screen where you could submit your score to the highscore list, but we're a bit more forgiving in tutorial mode." name:@"gameover"]; - self.currentTutorial = bubble; - [bubble release]; - } -} - - (void)randomlyAddObject:(ccTime)dt { FallingObject* object; -- cgit 1.4.1