diff options
Diffstat (limited to 'Classes/GameMode.m')
-rw-r--r-- | Classes/GameMode.m | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/Classes/GameMode.m b/Classes/GameMode.m index 7afbf20..8f695d1 100644 --- a/Classes/GameMode.m +++ b/Classes/GameMode.m | |||
@@ -12,7 +12,7 @@ | |||
12 | 12 | ||
13 | @implementation GameMode | 13 | @implementation GameMode |
14 | 14 | ||
15 | @synthesize cart, score, lives; | 15 | @synthesize cart, score, lives, isPaused; |
16 | 16 | ||
17 | + (CCScene*)scene | 17 | + (CCScene*)scene |
18 | { | 18 | { |
@@ -60,6 +60,8 @@ | |||
60 | [pauseMenu setPosition:ccp(480-8-16, 320-8-16)]; | 60 | [pauseMenu setPosition:ccp(480-8-16, 320-8-16)]; |
61 | [self addChild:pauseMenu]; | 61 | [self addChild:pauseMenu]; |
62 | } | 62 | } |
63 | |||
64 | isPaused = NO; | ||
63 | } | 65 | } |
64 | 66 | ||
65 | return self; | 67 | return self; |
@@ -98,8 +100,10 @@ | |||
98 | 100 | ||
99 | - (void)pause | 101 | - (void)pause |
100 | { | 102 | { |
101 | if ([self canPause]) | 103 | if (([self canPause]) && (!isPaused)) |
102 | { | 104 | { |
105 | isPaused = YES; | ||
106 | |||
103 | [self pauseSchedulerAndActions]; | 107 | [self pauseSchedulerAndActions]; |
104 | 108 | ||
105 | shadedLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)]; | 109 | shadedLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)]; |
@@ -126,18 +130,25 @@ | |||
126 | 130 | ||
127 | - (void)unpause | 131 | - (void)unpause |
128 | { | 132 | { |
129 | [[[CCDirector sharedDirector] runningScene] removeChild:shadedLayer cleanup:YES]; | 133 | if (isPaused) |
130 | [[[CCDirector sharedDirector] runningScene] removeChild:pauseLayer cleanup:YES]; | 134 | { |
131 | 135 | [[[CCDirector sharedDirector] runningScene] removeChild:shadedLayer cleanup:YES]; | |
132 | shadedLayer = nil; | 136 | [[[CCDirector sharedDirector] runningScene] removeChild:pauseLayer cleanup:YES]; |
133 | pauseLayer = nil; | 137 | |
134 | 138 | shadedLayer = nil; | |
135 | [self resumeSchedulerAndActions]; | 139 | pauseLayer = nil; |
140 | |||
141 | [self resumeSchedulerAndActions]; | ||
142 | |||
143 | isPaused = NO; | ||
144 | } | ||
136 | } | 145 | } |
137 | 146 | ||
138 | - (void)mainmenu | 147 | - (void)mainmenu |
139 | { | 148 | { |
140 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; | 149 | UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Cartographic" message:@"Are you sure you want to quit the currently playing game?" delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No", nil]; |
150 | [alert show]; | ||
151 | [alert release]; | ||
141 | } | 152 | } |
142 | 153 | ||
143 | - (void)setScore:(int)m_score | 154 | - (void)setScore:(int)m_score |
@@ -170,6 +181,14 @@ | |||
170 | delayedAction = nil; | 181 | delayedAction = nil; |
171 | } | 182 | } |
172 | 183 | ||
184 | - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex | ||
185 | { | ||
186 | if (buttonIndex == 0) | ||
187 | { | ||
188 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; | ||
189 | } | ||
190 | } | ||
191 | |||
173 | - (void)dealloc | 192 | - (void)dealloc |
174 | { | 193 | { |
175 | [objects release]; | 194 | [objects release]; |