图为崩溃的地方
操作为动画执行的时候
这是我封装的动画按钮的方法
void UIBotton::setanimats( const char* fileName_nor,const char* fileName_ovr,const char* fileName_dwn,int lengh ,int FrameNum)
{
//over动画
m_animate =NULL;
animation = Animation::create();
animation->retain();
//animation = NULL;
for (int i = 1; i <= lengh; i++)
{
if (i>=10)
{
char szImageFileName1 = {0};
char szImageFileName2 = {0};
sprintf(szImageFileName1,"%d.png",i);
strcpy(szImageFileName2,fileName_ovr);
strcat(szImageFileName2,szImageFileName1);
animation->addSpriteFrameWithFileName(szImageFileName2);
}
else
{
char szImageFileName1 = {0};
char szImageFileName2 = {0};
sprintf(szImageFileName1,"0%d.png",i);
strcpy(szImageFileName2,fileName_ovr);
strcat(szImageFileName2,szImageFileName1);
animation->addSpriteFrameWithFileName(szImageFileName2);
}
}
float a = lengh;
animation->setDelayPerUnit(1.0f / 30); // 这个动画包含lengh帧,将会持续1秒.
animation->setRestoreOriginalFrame(true); // 14帧播放完之后返回到第一帧
//CCLog("00000000000000000000000000000========%f",animation->getDuration());
Animate *action = Animate::create(animation);
m_animate = RepeatForever::create(action);
}
```
btn_MoreApp是一个动画按钮
每次鼠标OVER的时候会调用setanimats方法
然后执行这个动画
btn_MoreApp->setanimats(
btn_MoreApp->getSpriteName(),
btn_MoreApp->getSpriteName_ovr(),
btn_MoreApp->getSpriteName_dwn(),
btn_MoreApp->getSpriteLength(),
btn_MoreApp->getCurrFrameNum());
ActionInterval * myani = btn_MoreApp->getanimat();
btn_MoreApp->runAction(myani);
```
最后结束动画的时候 对animation release;
void UIBotton::endaction()
{
this->setSpriteFrame(SpriteFrame::create(sprites_name_nor,this->getTextureRect(),false,Point(0,0),this->getContentSize()));
this->stopAllActions();
this->animation->release();
}
```
这样造成了内存溢出
我也觉得代码有些问题的 但是不知道哪里出了问题
请教各位大神
给点合理化解决方案
多谢啦 :12::12::12:
