0

I have noticed that "purgeSharedAnimationCache" method call sets the "sharedAnimationCache_" to nil.

+(void)purgeSharedAnimationCache
{
    [sharedAnimationCache_ release];
    sharedAnimationCache_ = nil;
}

What happens when I then try to add a new CCAnimation to the CCAnimationCache? Will this create a new "sharedAnimationCache"?

mm24
  • 9,280
  • 12
  • 75
  • 170

1 Answers1

1

Yes, it will. Do purge carefully, or not at all, since the animation cache rarely holds any significant amount of memory.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • Time ago I was posting about a bug where I couldn't retrieve the texture frame name from a gluint. I have found that every time I was changing scene (via replaceScene) the CCAnimationCache was holding reference to the previous animations and, as the new scene had the same name for those animations, would crash as was not finding the correct texture batch node file name. I hence decided to add a "purgeSharedAnimationCache" call in the init method of each new GameScene and this helps (http://stackoverflow.com/questions/15208275/how-can-i-retrieve-the-corresponding-texture-name-from-a-gluint). – mm24 Jun 10 '13 at 08:55
  • @LearnCococs2D Is there any tutorial that explains what a CCAnimationCache is and how we should handle it during the GameScene changes in respect to the images being loaded in frame cache? (In other words, in order to avoid the App crashing if the Animation is still running whilst a scene is changing? This answer helped me a bit: http://stackoverflow.com/questions/17098141/cocos2d-and-concurrency-how-to-properly-stop-animations-between-scenes) – mm24 Jun 20 '13 at 09:42