summary refs log tree commit diff stats
path: root/Classes/GameOverScene.m
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-09-09 19:57:25 -0400
committerStarla Insigna <starla4444@gmail.com>2011-09-09 19:57:25 -0400
commitb090d12d637e5cfbf0ac6955fa6c8d401de657b5 (patch)
tree6992a95f48b5152be54ebfc409c2c9dcdd577a21 /Classes/GameOverScene.m
parent3cc8a6c48b6bf821ba8787850485de03b4d984e8 (diff)
downloadcartcollect-b090d12d637e5cfbf0ac6955fa6c8d401de657b5.tar.gz
cartcollect-b090d12d637e5cfbf0ac6955fa6c8d401de657b5.tar.bz2
cartcollect-b090d12d637e5cfbf0ac6955fa6c8d401de657b5.zip
Added play again button to game over screen
Closes #218
Diffstat (limited to 'Classes/GameOverScene.m')
-rwxr-xr-xClasses/GameOverScene.m36
1 files changed, 32 insertions, 4 deletions
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