Hi all
I'm having a problem that is really doing my head in.
So basically I have a MainMenuScene, which in turns creates a test layer. This layer is very simple as it only creates a score label and a button that is added to a menu.
When this button is pressed the MainMenuScene is replaced by a blank scene and then the MainMenuScene is loaded again.
So far so good. However the problem is when I take a heapshot in the instruments each time the scene is reloaded, I get a heap increase of around 20kb. When I dig deeper in the extended view it seems the sprite and font from the testLayer aren't being released and yet the dealloc method from the layer is being called.
I also add ARC support to my files except Cocos files. Could this be related in any way?
Here is the test layer:
@implementation TestLayer
-(id)init
{
self = [super initWithColor:ccc4(2,2,2,210)];
if (self != nil)
{
// ask director the the window size
CGSize s = [[CCDirector sharedDirector] winSize];
self.isTouchEnabled = YES;
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
formatter.numberStyle = NSNumberFormatterDecimalStyle;
NSNumber * n = [NSNumber numberWithInt:[SDCloudUserDefaults integerForKey:@"highscore"]];
NSString *string = [formatter stringFromNumber:n];
//score
CCLabelBMFont * scoreLabel = [CCLabelBMFont labelWithString:string fntFile:@"scoreFont.fnt" width:s.width alignment:kCCTextAlignmentCenter];
scoreLabel.position = ccp( POS_X(443), POS_Y(877) );
[self addChild:scoreLabel z:90];
//PLAY BUTTON
CCMenuItemSprite *playButton = [CCMenuItemSprite itemFromNormalSprite:[CCSprite spriteWithFile:@"play_up.png"]
selectedSprite:[CCSprite spriteWithFile:@"play_down.png"]
target:self
selector:@selector(Transition:)];
playButton.position = ccp( POS_X(380) , POS_Y(177));
menu = [CCMenu menuWithItems: playButton, nil];
menu.position = ccp(0, 0);
[self addChild: menu];
}
return self;
}
-(void) Transition:(ccTime) dt
{
[self unschedule:@selector(Transition:)];
[[SceneManager sharedSceneManager]RunSceneWithID:SCENE_LOADING:eCCTransitionCrossFade:1.0f];
}
- (void) dealloc
{
NSLog(@"%s",__FUNCTION__);
}
@end
I really can't see what is creating a leak or a retain so really would appreciate some guidance on this.
Thanks.