Hi,
I have read about retain, and release functions, and I’m a little bit confused. Actually I have an application that have to show full screen animations of 9 frames each one. Each time you touch the screen the app load a new 9 frames animation and run it.
The code in the myLayer::init() is
bool myLayer::init(){
//….All the needed code to init my layer
//…Issued code:
page_number=1;
CCAnimation* animation = CCAnimation::animation();
animation~~>setDelay;
//Loading the frames
char frameName[32];
for {
sprintf;
animation~~>addFrameWithFileName(frameName);
}
CCAnimate animate = CCAnimate::actionWithAnimation;
sprintf;
CCSpritespriteAnim = CCSprite::spriteWithFile(frameName);
spriteAnim~~>setPosition );
spriteAnim~~>runAction(animate);
this~~>addChild;
return true;
}
void myLayer::ccTouchesEnded{
//some code…
//Issued code:
//removing the old animation
if){
this~~>removeChildByTag(POWERPOINT, true);
}
CCAnimation* animation = CCAnimation::animation();
animation~~>setDelay;
//Loading the frames
char frameName[32];
for {
sprintf;
animation~~>addFrameWithFileName(frameName);
}
CCAnimate animate = CCAnimate::actionWithAnimation;
sprintf;
CCSpritespriteAnim = CCSprite::spriteWithFile(frameName);
spriteAnim~~>setPosition );
spriteAnim~~>runAction(animate);
this->addChild(spriteAnim, 15,ANIMATION_TAG);
}
Well, in my iPad simulator the app is working really good, but once I loaded in my device the app is crashing at the first touch (so it means the first animation is working, but 2nd one not). After checking some things, I have analyzed the behavior with instruments, and I can see each time the app is loading a new image “allocated memory” is growing up Why? I’m removing and forcing the animated Sprite to be cleaned up…
Please could you sugest some solution?
Many thanks!