如果移除SpriteFrameCache中的所有缓存?

我查到一个方法叫SpriteFrameCache->getInstance()->removeSpriteFrames(),相比其他的remove系列方法,这个从名字上看起来是最贴近删除所有缓存的方法了。

不过我看了它的描述以后,产生了疑惑,描述如下:
Call this method if you receive the “Memory Warning”. In the short term: it will free some resources preventing your app from being killed. In the medium term: it will allocate more resources. In the long term: it will be the same.

从描述看,这个方法并不像是清空所有缓存用的。那么,怎么才能清空所有SpriteFrameCache中的缓存呢?

Director::getInstance()->getTextureCache()->removeAllTextures();

:2: 怎么删除 所有动画缓存
AnimationCache::getInstance()->removeAnimation(<#const std::string &name#>)

只有一个函数 而且要参数 。

其实我一直想要删除一个plist中的所有帧动画的方法。

:12: 我不知道 这个 有没有效果。。。
AnimationCache::getInstance()->destroyInstance();

AnimationCache::getInstance()->destroyInstance()

然后搞错了一个… SpriteFrameCache应该是调用SpriteFrameCache::getInstance()->removeSpriteFrames();…不过最好是调用removeUnusedSpriteFrames删除没有用到的…

如果不是删除所有帧动画,只是删除一个plist里面定义的帧动画有没有办法?

这个我没试过,但是看源码可以知道,他也是加到TextureCache里面的,调用的是addImage函数。试试用Director::getInstance()->getTextureCache()->removeTextureForKey看看

感谢各位的回答,我恰好今天看到一篇教程,发出来跟大家分享,里面讲了三种缓存机制,非常详细!

http://cn.cocos2d-x.org/tutorial/show?id=2450

— Begin quote from ____

引用第6楼abc88798于2015-03-03 11:03发表的 :
然后搞错了一个… SpriteFrameCache应该是调用SpriteFrameCache::getInstance()->removeSpriteFrames();…不过最好是调用removeUnusedSpriteFrames删除没有用到的… http://www.cocoachina.com/bbs/job.php?action=topost&tid=286607&pid=1249984

— End quote

嗯,经测试,发现removeUnusedSpriteFrames确实挺好用的。