diff options
-rwxr-xr-x | Classes/GameOverScene.h | 4 | ||||
-rwxr-xr-x | Classes/GameOverScene.m | 36 |
2 files changed, 35 insertions, 5 deletions
diff --git a/Classes/GameOverScene.h b/Classes/GameOverScene.h index a91286e..f596211 100755 --- a/Classes/GameOverScene.h +++ b/Classes/GameOverScene.h | |||
@@ -17,13 +17,15 @@ | |||
17 | UISwitch* submitSwitch; | 17 | UISwitch* submitSwitch; |
18 | UIActivityIndicatorView* activityIndicator; | 18 | UIActivityIndicatorView* activityIndicator; |
19 | UIButton* backButton; | 19 | UIButton* backButton; |
20 | UIButton* playButton; | ||
20 | int score; | 21 | int score; |
21 | NSString* gameMode; | 22 | NSString* gameMode; |
23 | BOOL playAgain; | ||
22 | } | 24 | } |
23 | 25 | ||
24 | + (GameOverScene*)sceneWithScore:(int)score gameMode:(NSString*)gameMode; | 26 | + (GameOverScene*)sceneWithScore:(int)score gameMode:(NSString*)gameMode; |
25 | - (id)initWithScore:(int)score gameMode:(NSString*)gameMode; | 27 | - (id)initWithScore:(int)score gameMode:(NSString*)gameMode; |
26 | - (void)newgame; | 28 | - (void)newgame:(id)sender; |
27 | - (void)submitScore; | 29 | - (void)submitScore; |
28 | - (void)exit; | 30 | - (void)exit; |
29 | 31 | ||
diff --git a/Classes/GameOverScene.m b/Classes/GameOverScene.m index cfbb446..a56aeac 100755 --- a/Classes/GameOverScene.m +++ b/Classes/GameOverScene.m | |||
@@ -11,6 +11,8 @@ | |||
11 | #import <sqlite3.h> | 11 | #import <sqlite3.h> |
12 | #import "cocoslive.h" | 12 | #import "cocoslive.h" |
13 | #import "MainMenuLayer.h" | 13 | #import "MainMenuLayer.h" |
14 | #import "ClassicGameMode.h" | ||
15 | #import "JumpGameMode.h" | ||
14 | 16 | ||
15 | @implementation GameOverScene | 17 | @implementation GameOverScene |
16 | 18 | ||
@@ -64,11 +66,19 @@ | |||
64 | 66 | ||
65 | activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(480-20-10, 320-20-10, 20, 20)]; | 67 | activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(480-20-10, 320-20-10, 20, 20)]; |
66 | [movingLayer addSubview:activityIndicator]; | 68 | [movingLayer addSubview:activityIndicator]; |
69 | |||
70 | playButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; | ||
71 | [playButton setFrame:CGRectMake(480/3-105/2, 320-60-15, 105, 31)]; | ||
72 | [playButton setTitle:@"Play Again" forState:UIControlStateNormal]; | ||
73 | [playButton addTarget:self action:@selector(newgame:) forControlEvents:UIControlEventTouchUpInside]; | ||
74 | [playButton.titleLabel setFont:[UIFont systemFontOfSize:16.0]]; | ||
75 | [playButton.titleLabel setTextColor:[UIColor blackColor]]; | ||
76 | [movingLayer addSubview:playButton]; | ||
67 | 77 | ||
68 | backButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; | 78 | backButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; |
69 | [backButton setFrame:CGRectMake(240-154/2, 320-60-15, 154, 31)]; | 79 | [backButton setFrame:CGRectMake(480/3*2-154/2, 320-60-15, 154, 31)]; |
70 | [backButton setTitle:@"Back to Main Menu" forState:UIControlStateNormal]; | 80 | [backButton setTitle:@"Back to Main Menu" forState:UIControlStateNormal]; |
71 | [backButton addTarget:self action:@selector(newgame) forControlEvents:UIControlEventTouchUpInside]; | 81 | [backButton addTarget:self action:@selector(newgame:) forControlEvents:UIControlEventTouchUpInside]; |
72 | [backButton.titleLabel setFont:[UIFont systemFontOfSize:16.0]]; | 82 | [backButton.titleLabel setFont:[UIFont systemFontOfSize:16.0]]; |
73 | [backButton.titleLabel setTextColor:[UIColor blackColor]]; | 83 | [backButton.titleLabel setTextColor:[UIColor blackColor]]; |
74 | [movingLayer addSubview:backButton]; | 84 | [movingLayer addSubview:backButton]; |
@@ -83,8 +93,12 @@ | |||
83 | movingLayer.center = CGPointMake(240, 160-position.y); | 93 | movingLayer.center = CGPointMake(240, 160-position.y); |
84 | } | 94 | } |
85 | 95 | ||
86 | - (void)newgame | 96 | - (void)newgame:(id)sender |
87 | { | 97 | { |
98 | // Play again if the user pressed the play again button | ||
99 | playAgain = (sender == playButton); | ||
100 | |||
101 | playButton.enabled = NO; | ||
88 | backButton.enabled = NO; | 102 | backButton.enabled = NO; |
89 | textField.enabled = NO; | 103 | textField.enabled = NO; |
90 | submitSwitch.enabled = NO; | 104 | submitSwitch.enabled = NO; |
@@ -198,6 +212,9 @@ | |||
198 | [activityIndicator release]; | 212 | [activityIndicator release]; |
199 | activityIndicator = nil; | 213 | activityIndicator = nil; |
200 | 214 | ||
215 | [playButton removeFromSuperview]; | ||
216 | playButton = nil; | ||
217 | |||
201 | [backButton removeFromSuperview]; | 218 | [backButton removeFromSuperview]; |
202 | backButton = nil; | 219 | backButton = nil; |
203 | 220 | ||
@@ -205,7 +222,18 @@ | |||
205 | [movingLayer release]; | 222 | [movingLayer release]; |
206 | movingLayer = nil; | 223 | movingLayer = nil; |
207 | 224 | ||
208 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; | 225 | if (playAgain) |
226 | { | ||
227 | if ([gameMode isEqual:@"Collect"]) | ||
228 | { | ||
229 | [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[ClassicGameMode scene] withColor:ccc3(0, 0, 0)]]; | ||
230 | } else if ([gameMode isEqual:@"Jump"]) | ||
231 | { | ||
232 | [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[JumpGameMode scene] withColor:ccc3(0, 0, 0)]]; | ||
233 | } | ||
234 | } else { | ||
235 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; | ||
236 | } | ||
209 | } | 237 | } |
210 | 238 | ||
211 | @end | 239 | @end |