summary refs log tree commit diff stats
path: root/Classes/JumpGameMode.m
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-09-05 13:03:27 -0400
committerStarla Insigna <starla4444@gmail.com>2011-09-05 13:03:27 -0400
commitbbe409f5e34b5269ecbb7f61dbb8a793e2871d20 (patch)
treeb928d980abca3d1f1747362032061d592478556c /Classes/JumpGameMode.m
parent5af6401805f65a9b5968625d565613dd83edcfc7 (diff)
downloadcartcollect-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/JumpGameMode.m')
-rw-r--r--Classes/JumpGameMode.m12
1 files changed, 9 insertions, 3 deletions
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])