From bbe409f5e34b5269ecbb7f61dbb8a793e2871d20 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Mon, 5 Sep 2011 13:03:27 -0400 Subject: 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 --- Classes/JumpGameMode.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Classes/JumpGameMode.m') 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 @@ factory = [[LedgeFactory alloc] init]; ledges = [[NSMutableSet alloc] init]; - CCSprite* ledge = [CCSprite spriteWithTexture:[[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:6 height:2]]]; + CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:6 height:2]]; + CCSprite* ledge = [CCSprite spriteWithTexture:texture]; ledge.position = ccp(80, 32); [self addChild:ledge]; [ledges addObject:ledge]; + [texture release]; CCSprite* firstLedge = ledge; - ledge = [CCSprite spriteWithTexture:[[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:10 height:2]]]; + texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:10 height:2]]; + ledge = [CCSprite spriteWithTexture:texture]; ledge.position = ccp(80 + firstLedge.boundingBox.size.width/2 + ledge.boundingBox.size.width/2+64, 32); [self addChild:ledge]; [ledges addObject:ledge]; + [texture release]; ledgeScrollSpeed = 0; ledgeAccelerationRate = 20.0f; @@ -125,10 +129,12 @@ if (rightmost <= 480) { - CCSprite* ledge = [CCSprite spriteWithTexture:[[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:(arc4random() % 10) height:2]]]; + CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:(arc4random() % 10) height:2]]; + CCSprite* ledge = [CCSprite spriteWithTexture:texture]; ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64, 32); [self addChild:ledge]; [ledges addObject:ledge]; + [texture release]; } if ([self cartIsObstructed:cart]) -- cgit 1.4.1