void PlayerSprite::updateAnimation(CCString* cUrl)
{
CCArray* arr=CCArray::create();
for(int i=npcPro->dir*8;i<=npcPro->dir*8+7;i++)
{
CCSpriteFrame* frame=CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat(cUrl->getCString(),i+1)->getCString());
arr->addObject(frame);
}
CCAnimation* anima=CCAnimation::createWithSpriteFrames(arr,0.2f);
anima->setLoops(-1);
this->runAction(CCAnimate::create(anima));
arr->release();
}
在初始化里
this->updateAnimation(_npcPro->npcUrlPao);
this->updateAnimation(_npcPro->npcUrlPao);
this->updateAnimation(_npcPro->npcUrlPao);
这样很多次都正常。 只显示12345678
传给别的对象后 在调用的时候就重复了
比如在别的对象里
this->pSprite->updateAnimation(this->pSprite->_npcPro->npcUrlPao);
前面的动画就不消失了 显示1234567812345678 12345678…………
都重复了 精灵动起来越来越快 。
这啥问题啊..新手 求赐教。
{
CCArray* arr=CCArray::create();
for(int i=npcPro->dir*8;i<=npcPro->dir*8+7;i++)
{
CCSpriteFrame* frame=CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat(cUrl->getCString(),i+1)->getCString());
arr->addObject(frame);
}
CCAnimation* anima=CCAnimation::createWithSpriteFrames(arr,0.2f);
anima->setLoops(-1);
this->runAction(CCAnimate::create(anima));
arr->release();
}
在初始化里
this->updateAnimation(_npcPro->npcUrlPao);
this->updateAnimation(_npcPro->npcUrlPao);
this->updateAnimation(_npcPro->npcUrlPao);
这样很多次都正常。 只显示12345678
传给别的对象后 在调用的时候就重复了
比如在别的对象里
this->pSprite->updateAnimation(this->pSprite->_npcPro->npcUrlPao);
前面的动画就不消失了 显示1234567812345678 12345678…………
都重复了 精灵动起来越来越快 。
这啥问题啊..新手 求赐教。









