diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-09-05 13:03:27 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-09-05 13:03:27 -0400 |
commit | bbe409f5e34b5269ecbb7f61dbb8a793e2871d20 (patch) | |
tree | b928d980abca3d1f1747362032061d592478556c /Classes | |
parent | 5af6401805f65a9b5968625d565613dd83edcfc7 (diff) | |
download | cartcollect-bbe409f5e34b5269ecbb7f61dbb8a793e2871d20.tar.gz cartcollect-bbe409f5e34b5269ecbb7f61dbb8a793e2871d20.tar.bz2 cartcollect-bbe409f5e34b5269ecbb7f61dbb8a793e2871d20.zip |
Made general memory fixes
This revision should also hopefully fix the undefined behavior GameOverScene bug--if it, I'll reopen the ticket and continue investigating. Fixes #215
Diffstat (limited to 'Classes')
-rwxr-xr-x | Classes/GameOverScene.m | 6 | ||||
-rwxr-xr-x | Classes/Highscore.m | 2 | ||||
-rwxr-xr-x | Classes/HighscoreListController.m | 10 | ||||
-rw-r--r-- | Classes/JumpGameMode.m | 12 |
4 files changed, 23 insertions, 7 deletions
diff --git a/Classes/GameOverScene.m b/Classes/GameOverScene.m index 28c59ec..cfbb446 100755 --- a/Classes/GameOverScene.m +++ b/Classes/GameOverScene.m | |||
@@ -184,20 +184,26 @@ | |||
184 | 184 | ||
185 | [submitSwitch removeFromSuperview]; | 185 | [submitSwitch removeFromSuperview]; |
186 | [submitSwitch release]; | 186 | [submitSwitch release]; |
187 | submitSwitch = nil; | ||
187 | 188 | ||
188 | [textField removeFromSuperview]; | 189 | [textField removeFromSuperview]; |
189 | [textField release]; | 190 | [textField release]; |
191 | textField = nil; | ||
190 | 192 | ||
191 | [scoreField removeFromSuperview]; | 193 | [scoreField removeFromSuperview]; |
192 | [scoreField release]; | 194 | [scoreField release]; |
195 | scoreField = nil; | ||
193 | 196 | ||
194 | [activityIndicator removeFromSuperview]; | 197 | [activityIndicator removeFromSuperview]; |
195 | [activityIndicator release]; | 198 | [activityIndicator release]; |
199 | activityIndicator = nil; | ||
196 | 200 | ||
197 | [backButton removeFromSuperview]; | 201 | [backButton removeFromSuperview]; |
202 | backButton = nil; | ||
198 | 203 | ||
199 | [movingLayer removeFromSuperview]; | 204 | [movingLayer removeFromSuperview]; |
200 | [movingLayer release]; | 205 | [movingLayer release]; |
206 | movingLayer = nil; | ||
201 | 207 | ||
202 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; | 208 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; |
203 | } | 209 | } |
diff --git a/Classes/Highscore.m b/Classes/Highscore.m index 546cbfe..e459d48 100755 --- a/Classes/Highscore.m +++ b/Classes/Highscore.m | |||
@@ -50,7 +50,7 @@ | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | return [highscores copy]; | 53 | return [[highscores copy] autorelease]; |
54 | } | 54 | } |
55 | 55 | ||
56 | + (Highscore*)localHighscoreForGameMode:(NSString*)gameMode | 56 | + (Highscore*)localHighscoreForGameMode:(NSString*)gameMode |
diff --git a/Classes/HighscoreListController.m b/Classes/HighscoreListController.m index 7dbefa1..7370da5 100755 --- a/Classes/HighscoreListController.m +++ b/Classes/HighscoreListController.m | |||
@@ -22,7 +22,7 @@ | |||
22 | // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. | 22 | // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. |
23 | self = [super initWithStyle:style]; | 23 | self = [super initWithStyle:style]; |
24 | if (self) { | 24 | if (self) { |
25 | localHighscores = [Highscore localHighscoreListForGameMode:@"Collect"]; | 25 | localHighscores = [[Highscore localHighscoreListForGameMode:@"Collect"] retain]; |
26 | 26 | ||
27 | navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; | 27 | navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; |
28 | myNavigationItem = [[UINavigationItem alloc] initWithTitle:@"Highscores"]; | 28 | myNavigationItem = [[UINavigationItem alloc] initWithTitle:@"Highscores"]; |
@@ -48,6 +48,7 @@ | |||
48 | toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 480-44, 320, 44)]; | 48 | toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 480-44, 320, 44)]; |
49 | [toolbar setItems:[NSArray arrayWithObjects:barButton3, btnSpace, barButton2, nil] animated:NO]; | 49 | [toolbar setItems:[NSArray arrayWithObjects:barButton3, btnSpace, barButton2, nil] animated:NO]; |
50 | [barButton2 release]; | 50 | [barButton2 release]; |
51 | [btnSpace release]; | ||
51 | [barButton3 release]; | 52 | [barButton3 release]; |
52 | 53 | ||
53 | showGlobal = NO; | 54 | showGlobal = NO; |
@@ -326,13 +327,16 @@ | |||
326 | 327 | ||
327 | - (void)switchGameMode:(id)sender | 328 | - (void)switchGameMode:(id)sender |
328 | { | 329 | { |
330 | [localHighscores release]; | ||
331 | |||
329 | if ([(UISegmentedControl*)sender selectedSegmentIndex] == 0) | 332 | if ([(UISegmentedControl*)sender selectedSegmentIndex] == 0) |
330 | { | 333 | { |
331 | localHighscores = [Highscore localHighscoreListForGameMode:@"Collect"]; | 334 | localHighscores = [[Highscore localHighscoreListForGameMode:@"Collect"] retain]; |
332 | } else { | 335 | } else { |
333 | localHighscores = [Highscore localHighscoreListForGameMode:@"Jump"]; | 336 | localHighscores = [[Highscore localHighscoreListForGameMode:@"Jump"] retain]; |
334 | } | 337 | } |
335 | 338 | ||
339 | [globalHighscores release]; | ||
336 | globalHighscores = nil; | 340 | globalHighscores = nil; |
337 | 341 | ||
338 | [self switchLists:areaControl]; | 342 | [self switchLists:areaControl]; |
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 907effc..7299160 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m | |||
@@ -56,16 +56,20 @@ | |||
56 | 56 | ||
57 | factory = [[LedgeFactory alloc] init]; | 57 | factory = [[LedgeFactory alloc] init]; |
58 | ledges = [[NSMutableSet alloc] init]; | 58 | ledges = [[NSMutableSet alloc] init]; |
59 | CCSprite* ledge = [CCSprite spriteWithTexture:[[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:6 height:2]]]; | 59 | CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:6 height:2]]; |
60 | CCSprite* ledge = [CCSprite spriteWithTexture:texture]; | ||
60 | ledge.position = ccp(80, 32); | 61 | ledge.position = ccp(80, 32); |
61 | [self addChild:ledge]; | 62 | [self addChild:ledge]; |
62 | [ledges addObject:ledge]; | 63 | [ledges addObject:ledge]; |
64 | [texture release]; | ||
63 | 65 | ||
64 | CCSprite* firstLedge = ledge; | 66 | CCSprite* firstLedge = ledge; |
65 | ledge = [CCSprite spriteWithTexture:[[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:10 height:2]]]; | 67 | texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:10 height:2]]; |
68 | ledge = [CCSprite spriteWithTexture:texture]; | ||
66 | ledge.position = ccp(80 + firstLedge.boundingBox.size.width/2 + ledge.boundingBox.size.width/2+64, 32); | 69 | ledge.position = ccp(80 + firstLedge.boundingBox.size.width/2 + ledge.boundingBox.size.width/2+64, 32); |
67 | [self addChild:ledge]; | 70 | [self addChild:ledge]; |
68 | [ledges addObject:ledge]; | 71 | [ledges addObject:ledge]; |
72 | [texture release]; | ||
69 | 73 | ||
70 | ledgeScrollSpeed = 0; | 74 | ledgeScrollSpeed = 0; |
71 | ledgeAccelerationRate = 20.0f; | 75 | ledgeAccelerationRate = 20.0f; |
@@ -125,10 +129,12 @@ | |||
125 | 129 | ||
126 | if (rightmost <= 480) | 130 | if (rightmost <= 480) |
127 | { | 131 | { |
128 | CCSprite* ledge = [CCSprite spriteWithTexture:[[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:(arc4random() % 10) height:2]]]; | 132 | CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:(arc4random() % 10) height:2]]; |
133 | CCSprite* ledge = [CCSprite spriteWithTexture:texture]; | ||
129 | ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64, 32); | 134 | ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64, 32); |
130 | [self addChild:ledge]; | 135 | [self addChild:ledge]; |
131 | [ledges addObject:ledge]; | 136 | [ledges addObject:ledge]; |
137 | [texture release]; | ||
132 | } | 138 | } |
133 | 139 | ||
134 | if ([self cartIsObstructed:cart]) | 140 | if ([self cartIsObstructed:cart]) |