我的对象继承了一个Layer,.然后有一个成员变量Sprite
我用Sprite进行图片的显示和动画
Layer本身进行移动和特效动作处理
第一次创建使用时,图片正确和动画都是正确显示的
但是当放入对象池再取出来以后,发现 Sprite创建出来的对象就是没有图片和动画
这是为什么,难道使用方法有什么问题
//开始初始化
char str;
sprintf(str, “fish0%d_01.png”, 2);
m_pSprite = Sprite::createWithSpriteFrameName(str);
m_pSprite->setAnchorPoint(Point(0, 0));
this->addChild(m_pSprite);
this->setTag(COLLIDER_FISH);
this->ignoreAnchorPointForPosition(false);
m_nWidth = m_pSprite->getContentSize().width;
m_nHeight = m_pSprite->getContentSize().height;
this->setContentSize(m_pSprite->getContentSize());
auto ani = AnimationCache::getInstance()->getAnimation("fish2");
auto animate = Animate::create(ani);
m_pSprite->runAction(animate);
//结束
this->removeChild(m_pSprite);
//返还对象
FishLayer* layer = (FishLayer*)this->getParent();
layer->BackObj(this);