CCAramature的问题(cocos2d-x 2.2.5)

CCArmature *p1 = CCArmature::create();
addChild(p1);
启用定时器,5秒后执行
p1->init(“b”);
p1->getAnimation()->playerWithIndex(0);
这个没有问题,动画正常播放,
但是再通过定时器,8秒后执行以下代码会出现当机
p1->getAnimation()->stop();
p1->init(“c”);
p1->getAnimation()->playerWithIndex(0);

我就想确认一定,CCArmature 到底支持 不创建对象而动态修改动画吗?

你好,你能说一下您的需求么?
这个代码看上去有一些问题,但是我不知道你要做什么

功能说明: 通过 CCAramature ::create创建对象p1, 将p1加入层中并播放,开启用定时器,两秒后,执行以下代码播放另一个动画
p1->getAnimation()->stop();
p1->init(“c”); 其中“c”为另一个动画名
p1->getAnimation()->playerWithIndex(0); 从而不需要再创建对象来播放别一个动画。
说明:两个动画需要的数据 均通过 addArmatureFileInfo 添加了
PS:当机的原因我找到了,是CCArmature::init(const char *name) 函数中加上以下语句就好了
if(m_pAtlas != NULL)
{
m_pAtlas = NULL;
}
在cocos2d-x 3.2中不存在这个bug

功能说明: 通过 CCAramature ::create创建对象p1, 将p1加入层中并播放,开启用定时器,两秒后,执行以下代码播放另一个动画
p1->getAnimation()->stop();
p1->init(“c”); 其中“c”为另一个动画名
p1->getAnimation()->playerWithIndex(0); 从而不需要再创建对象来播放别一个动画。
说明:两个动画需要的数据 均通过 addArmatureFileInfo 添加了
PS:当机的原因我找到了,是CCArmature::init(const char *name) 函数中加上以下语句就好了
if(m_pAtlas != NULL)
{
m_pAtlas = NULL;
}
在cocos2d-x 3.2中不存在这个bug