问题很简单,就像这个线程的提示一样。
生成具有相同名称但内容不同的新图像文件。
我确定该文件是从头开始生成的。(使用 iexplorer 检查并可以看到
生成了具有新内容的新图像)但是 CCsprite 以某种方式加载了第一个生成的同名文件。
不确定 CCspriteFrame 是否缓存它。
purgeSharedSpriteCache 或 removeUnusedSpriteFrames 不会删除它(如果是的话)
那么你更喜欢我什么?
{
NSArray *docs=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath=[docs objectAtIndex:0];
NSString *fn=[docPath stringByAppendingPathComponent:@"tmp.png"];
if([[NSFileManager defaultManager]fileExistsAtPath:fn])
{
//[CCSpriteFrameCache purgeSharedSpriteFrameCache];
//[[CCSpriteFrameCache sharedSpriteFrameCache]removeUnusedSpriteFrames];
//[[CCSpriteFrameCache sharedSpriteFrameCache]removeSpriteFrames];
CCSprite *firstSprite=[CCSprite spriteWithFile:fn];
[self regenerateNewTmpPng];//this deletes old tmp.png and generates imagefile with same name but different content
CCSprite *secondSprite=[CCSprite spriteWithFile:fn];//this loads same content as squareSprite
}
}