summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-08-23 12:55:57 -0400
committerStarla Insigna <starla4444@gmail.com>2011-08-23 12:55:57 -0400
commitb4c612674d28bf7b385bd9fe41b108df8d97b474 (patch)
treebe0326b097430746a00742f502fb461af97645b7
parent6b7e5a28aa9c52c5b689860a7c51de04ee5489c1 (diff)
downloadcartcollect-b4c612674d28bf7b385bd9fe41b108df8d97b474.tar.gz
cartcollect-b4c612674d28bf7b385bd9fe41b108df8d97b474.tar.bz2
cartcollect-b4c612674d28bf7b385bd9fe41b108df8d97b474.zip
Added pause checks to GameMode
Now GameMode actually checks if it's already paused before pausing.

Fixes #210
-rw-r--r--Classes/GameMode.h3
-rw-r--r--Classes/GameMode.m27
2 files changed, 21 insertions, 9 deletions
diff --git a/Classes/GameMode.h b/Classes/GameMode.h index 370550c..890106e 100644 --- a/Classes/GameMode.h +++ b/Classes/GameMode.h
@@ -25,11 +25,14 @@
25 CCLabelBMFont* livesLabel; 25 CCLabelBMFont* livesLabel;
26 26
27 void (^delayedAction)(void); 27 void (^delayedAction)(void);
28
29 BOOL isPaused;
28} 30}
29 31
30@property (readonly) Cart* cart; 32@property (readonly) Cart* cart;
31@property (nonatomic,assign) int score; 33@property (nonatomic,assign) int score;
32@property (nonatomic,assign) int lives; 34@property (nonatomic,assign) int lives;
35@property (readonly) BOOL isPaused;
33+ (CCScene*)scene; 36+ (CCScene*)scene;
34- (void)tick:(ccTime)dt; 37- (void)tick:(ccTime)dt;
35- (BOOL)canPause; 38- (BOOL)canPause;
diff --git a/Classes/GameMode.m b/Classes/GameMode.m index 7afbf20..7b07f15 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,13 +130,18 @@
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