I am facing an issue with deleting the sprite sheets and freeing the memory
I am adding the complete animal sprite batchnode and sprite frame by this code:
// —— init animal variables ——————————————
string animalSpriteFile = animal.pvr.ccz
string animalSpritePlist = animal.plist
// ------ add animal batch node ------------------------------------------
CCSpriteBatchNode *animalBatchNode = CCSpriteBatchNode::create(animalSpriteFile.c_str());
CCSpriteFrameCache* animalSpriteCache = CCSpriteFrameCache::sharedSpriteFrameCache();
animalSpriteCache->addSpriteFramesWithFile(animalSpritePlist.c_str());
this->addChild(animalBatchNode );
// add the animal
CCSprite* animal = CCSprite::createWithSpriteFrameName(animalImgNames[0].c_str());
animal->setPosition(ccp(posX, posY));
animalBatchNode->addChild(animal, z_Index++);
// animate the animal
CCArray* animFrames = CCArray::createWithCapacity(totalAnimalSprites);
for(int k = 0; k spriteFrameByName(animalImgNames[k].c_str());
animFrames->addObject(frame);
}
CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, animalAnimSpeed);
animal->runAction(CCRepeatForever::create(CCAnimate::create(animation)));
//=====================================
Now I am removing the complete animal with batchnode and sprite frame by this code:
// --------------------------------------------------------------
animal->stopAllActions();
for(int k = 0; kremoveTextureForKey (animalImgNames[k].c_str());
}
for(int k = 0; k removeSpriteFrameByName(animalImgNames[k].c_str());
}
CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFramesFromFile(animalSpritePlist.c_str());
animalBatchNode->removeAllChildrenWithCleanup(true);
this->removeChild(animalBatchNode, true);
//=====================================
I have some 4 different types of animals so when these animals are added, 7 MB of memory is being added.
But when I am removing the animals, there is no change in memory usage…
Please point me where am I wrong? I want this memory usage to be remove completely.
Thanks
ediston