diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-08-17 21:10:55 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-08-17 21:10:55 -0400 |
commit | 93f26235d891b7558aaf8aa0353104cdec3609c9 (patch) | |
tree | 33936e2b5a34817daf444358f2dbb2c5c56f09f2 /Classes | |
parent | fee8d3506b4c2f6d5933a85181de9bb8e6f5fcc4 (diff) | |
download | cartcollect-93f26235d891b7558aaf8aa0353104cdec3609c9.tar.gz cartcollect-93f26235d891b7558aaf8aa0353104cdec3609c9.tar.bz2 cartcollect-93f26235d891b7558aaf8aa0353104cdec3609c9.zip |
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
Diffstat (limited to 'Classes')
-rw-r--r-- | Classes/TutorialMode.m | 45 |
1 files 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 @@ | |||
20 | // 2002 - items that are dropped after you miss first dropped item to demonstrate what happens when you catch | 20 | // 2002 - items that are dropped after you miss first dropped item to demonstrate what happens when you catch |
21 | // 2003 - 1-Up | 21 | // 2003 - 1-Up |
22 | // 2009 - rock | 22 | // 2009 - rock |
23 | // 2010 - random item dropped after death from first rock | ||
23 | 24 | ||
24 | @implementation TutorialMode | 25 | @implementation TutorialMode |
25 | 26 | ||
@@ -122,10 +123,33 @@ | |||
122 | [self schedule:@selector(randomlyAddObject:) interval:2.5f]; | 123 | [self schedule:@selector(randomlyAddObject:) interval:2.5f]; |
123 | } else if (item.sprite.tag == 2009) | 124 | } else if (item.sprite.tag == 2009) |
124 | { | 125 | { |
126 | if ((lives < 1) && (!showedDeathBubble)) | ||
127 | { | ||
128 | showedDeathBubble = YES; | ||
129 | |||
130 | 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"]; | ||
131 | self.currentTutorial = bubble; | ||
132 | [bubble release]; | ||
133 | } else { | ||
134 | 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"]; | ||
135 | self.currentTutorial = bubble; | ||
136 | [bubble release]; | ||
137 | } | ||
138 | } else if (item.sprite.tag == 2010) | ||
139 | { | ||
125 | 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"]; | 140 | 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"]; |
126 | self.currentTutorial = bubble; | 141 | self.currentTutorial = bubble; |
127 | [bubble release]; | 142 | [bubble release]; |
128 | } | 143 | } |
144 | |||
145 | if ((lives < 1) && (!showedDeathBubble)) | ||
146 | { | ||
147 | showedDeathBubble = YES; | ||
148 | |||
149 | 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"]; | ||
150 | self.currentTutorial = bubble; | ||
151 | [bubble release]; | ||
152 | } | ||
129 | } | 153 | } |
130 | 154 | ||
131 | - (void)setCurrentTutorial:(TutorialBubble *)m_currentTutorial | 155 | - (void)setCurrentTutorial:(TutorialBubble *)m_currentTutorial |
@@ -191,6 +215,13 @@ | |||
191 | object.sprite.tag = 2003; | 215 | object.sprite.tag = 2003; |
192 | [object release]; | 216 | [object release]; |
193 | } delay:2.0f]; | 217 | } delay:2.0f]; |
218 | } else if ([currentTutorial.name isEqual:@"gameover-rock"]) | ||
219 | { | ||
220 | [self scheduleDelayedAction:^{ | ||
221 | FallingObject* object = [self dropRandomItem]; | ||
222 | object.sprite.tag = 2010; | ||
223 | [object release]; | ||
224 | } delay:1.0f]; | ||
194 | } else if ([currentTutorial.name isEqual:@"intense"]) | 225 | } else if ([currentTutorial.name isEqual:@"intense"]) |
195 | { | 226 | { |
196 | [self schedule:@selector(randomlyAddObject:) interval:1.0f]; | 227 | [self schedule:@selector(randomlyAddObject:) interval:1.0f]; |
@@ -252,20 +283,6 @@ | |||
252 | return [self dropSpecificItem:object]; | 283 | return [self dropSpecificItem:object]; |
253 | } | 284 | } |
254 | 285 | ||
255 | - (void)setLives:(int)m_lives | ||
256 | { | ||
257 | [super setLives:m_lives]; | ||
258 | |||
259 | if ((lives < 1) && (!showedDeathBubble)) | ||
260 | { | ||
261 | showedDeathBubble = YES; | ||
262 | |||
263 | 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"]; | ||
264 | self.currentTutorial = bubble; | ||
265 | [bubble release]; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | - (void)randomlyAddObject:(ccTime)dt | 286 | - (void)randomlyAddObject:(ccTime)dt |
270 | { | 287 | { |
271 | FallingObject* object; | 288 | FallingObject* object; |