Sorry for my poor English.
I'm new in Cocos2D and I have two problems with the memory management.
1. I wrote an application with two scenes, each with the label, the menu and the picture, and I do not know how to release them(menu, label, picture). For example:
- (void) dealloc
{
[SpriteName release]
[super dealloc];
}
doesn't work.
2. Although the images are about 400kb, memory increases to 5Mb, and I have no idea why.
I will be grateful for help.
xCode Project:
Mirror 1 : http://www.mediafire.com/?3br311jb44nn2xg
Mirror 2: http://www.megaupload.com/?d=YO0W679K
First Scene Code( Second scene is very similar )
.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "SecondScene.h"
@interface FirstScene : CCLayer {
CCSprite *image1;
}
+(id) scene;
@end
.m
#import "FirstScene.h"
@implementation FirstScene
+(id) scene
{
CCScene *scene = [CCScene node];
FirstScene *layer = [FirstScene node];
[scene addChild: layer];
return scene;
}
-(id) init
{
if( (self=[super init] )) {
// Image 1
image1 = [CCSprite spriteWithFile:@"image1.png"];
image1.position = ccp(160,170);
[self addChild:image1];
// Menu
CCMenuItemImage *button1 = [CCMenuItemImage itemFromNormalImage:@"button.png" selectedImage:@"button.png" target:self selector:@selector(button1:)];
CCMenu *menu = [CCMenu menuWithItems:button1, nil];
[menu alignItemsVertically];
menu.position = ccp(371, 158);
[self addChild: menu];
// Label
CCLabel *label = [CCLabel labelWithString:@"Next" fontName:@"Arial" fontSize:30];
label.position = ccp(362,162);
label.color = ccc3(0,0,0);
[self addChild: label];
}
return self;
}
-(void) button1: (id) sender {
[[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:0.5 scene:[SecondScene node]]];
}
- (void) dealloc
{
[super dealloc];
}
@end