Hi there,
I'm new to Objective C as a whole, so I'm struggling to make sure I implement memory management correctly within my sparrow framework game.
I've created 3 screens (that extend sprite) - a start screen, game screen and game over screen. I've copied the screen management system used in the sparrow demo whereby there is a single "current screen" variable retained in the game implementation.
The problem I have is that when I call removeFromParent on that and set it to nil, dealloc is never executed on any of my screens. This means it quickly runs out of memory if I run it on a real device. I am instantiating my screens in the same way that this is done in the demo:
- SPSPrite * scene = [[GameScreen alloc] init];
- [scene addEventListener:@selector(onComplete:) atObject:self forType: EVENT_COMPLETE];
- currentScene = scene;
- [self addChild:scene atIndex:0];
- [scene release];
Am I missing something obvious? If I try to call release on the currentScreen variable when I change screen, rather than removeFromParent and setting it to nil, everything breaks.
cheers,
Alex