想给武器加个特效。。加上以后粒子不跟着骨骼移动。。何解?望往来路过的大神指点一下,代码其实和testcpp里的一样。。,如下
CCParticleSystem* weapon_tx = CCParticleSystemQuad::create(“equip/king_tx/fstexiao.plist”);
cocos2d::extension::CCBone *bone = cocos2d::extension::CCBone::create(“tx”);
bone->addDisplay(weapon_tx, 0);
bone->changeDisplayByIndex(0, true);
bone->setIgnoreMovementBoneData(true);
bone->setZOrder(100);
bone->setScale(0.4f);
hero->addBone(bone, “wuqi1”);

我是建个骨骼,渲染资源放粒子,父子链接到武器上。于是粒子跟着武器走了……貌似程序那边打开武器特效就是跟着角色动的。
在网上找到了的成功案例,不知道是否有帮助:
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfoAsync(“armature/robot.png”, “armature/robot.plist”, “armature/robot.xml”, this, NULL);
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfoAsync(“armature/hero.ExportJson”, this, NULL);
void TestParticleDisplay::onEnter()
{
ArmatureTestLayer::onEnter();
setTouchEnabled(true);
animationID = 0;
armature = cocos2d::extension::CCArmature::create("robot");
armature->getAnimation()->playWithIndex(0);
armature->setPosition(VisibleRect::center());
armature->setScale(0.48f);
armature->getAnimation()->setSpeedScale(0.5f);
addChild(armature);
CCParticleSystem *p1 = CCParticleSystemQuad::create("Particles/SmallSun.plist");
CCParticleSystem *p2 = CCParticleSystemQuad::create("Particles/SmallSun.plist");
cocos2d::extension::CCBone *bone = cocos2d::extension::CCBone::create("p1");
bone->addDisplay(p1, 0);
bone->changeDisplayWithIndex(0, true);
bone->setIgnoreMovementBoneData(true);
bone->setZOrder(100);
bone->setScale(1.2f);
armature->addBone(bone, "bady-a3");
bone = cocos2d::extension::CCBone::create("p2");
bone->addDisplay(p2, 0);
bone->changeDisplayWithIndex(0, true);
bone->setIgnoreMovementBoneData(true);
bone->setZOrder(100);
bone->setScale(1.2f);
armature->addBone(bone, "bady-a30");
}
bool TestParticleDisplay::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
++animationID;
animationID = animationID % armature->getAnimation()->getMovementCount();
armature->getAnimation()->playWithIndex(animationID);
return false;
}