thread 1: EXC_BADACCESS(code=2, address=0x14)
CCPoint& CCPoint::operator= (constCCPoint& other)
{
setPoint(other.x, other.y);
return *this;
}
错误提示到这里,说明 引用了已经释放的ccpoint对象持续更新中;
----------------------------------
调出debug navigator,发现GameLayer::update出问题,点击该行发现
sprite->runAction((CCAction *)_explosion->copy()->autorelease());该行肯定有对象为空,以至于在该行调用的时候,产生 EXC_BADACCESS,
再次查找sprite发现没有问题,检查_explosion发现
animation = CCAnimation::create();
for (int i = 0; i <= 7; i++) {
name = CCString::createWithFormat("explosion_small%i.png", i);
frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
animation->addSpriteFrame(frame);
}
animation->setDelayPerUnit(0.5/7.0f);
animation->setRestoreOriginalFrame(true);
_explosion = CCSequence::create(CCAnimate::create(animation),
CCCallFuncN::create(this, callfuncN_selector(GameLayer::animationDone)),
NULL);
_explosion->retain();
检查ccsppriteFrameCache也加载进来了,接着检查发现当i = 0的时候name为空,也即是frame为空,去sprite_sheet.plist里面找到该图片的描述,发现名字是从1开始的,即
explosion_small1,explosion_small2,,,,等一直到7,
至此,终于找到了错误的原因。
写代码不细心的惹的祸啊。