views:

25

answers:

0

Hi,

I am creating an animation in a scene(the current level) and so in the init section I add the required frames into the spriteFrameCache.

 [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"OchoHit.plist"];
  CCSpriteSheet *spriteSheet1 = [CCSpriteSheet spriteSheetWithFile:@"OchoHit.png"];
  [self addChild:spriteSheet1];

  [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"OchoHit2.plist"];
  CCSpriteSheet *spriteSheet2 = [CCSpriteSheet spriteSheetWithFile:@"OchoHit2.png"];
  [self addChild:spriteSheet2];

Also, I have a separate class OchoActions where I have initialized an animation

  [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Ocho.plist"];
  CCSpriteSheet *spriteSheet = [CCSpriteSheet spriteSheetWithFile:@"Ocho.png"];

  [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"OchoJump.plist"];
  CCSpriteSheet *spriteSheet1 = [CCSpriteSheet spriteSheetWithFile:@"OchoJump.png"];
  [self addChild:spriteSheet1];

which I call in the scene. The animation I have initialized in this class is something I would be using in every level. I use the following to create an object of the class to be used in the scene.

                OchoActions *ocho;
  ocho = [[OchoActions alloc] init];
  [self addChild:[ocho getOcho] z:1];

I am now unsure on where and how to release the frames.

Do I call [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames] in the dealloc of the scene or in the dealloc of the class?

Do I need to release the sprite frames added in the class? Cuz I wud need it again in the next scene. But if I do not release it will it not keep getting added again and again every level?

Is it necessary to call [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames] or should I use an alternate method to remove the spriteFrames?

How do I find out if I am undesirably continuing to add sprite frames again and again to the cache? What is the best practice to remove sprite frames?

Thanks Abhinav