Question about retaining spriteFrames

Question about retaining spriteFrames
0.0 0


Is there a way to manually increase the retain count of frames loaded with CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“”); I have a few spriteFrames loaded with this method that I do not want to be discarded when I call CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames();

I looked at the source, and I am pretty sure the answer is no, but I figured I would ask before writing my own method to do so. Thanks!


You can invoke CCSpriteFrameCache::spriteFrameByName(const char**) to get the CCSpriteFrame** pointer, then call pSpriteFrame->retain() in your code. But don’t forget to release them.