如何给spine骨骼动画挂载粒子特效
1个回答
推荐于2016-09-14 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517199
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
//init
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
CCSkeletonAnimation* skeletonNode = CCSkeletonAnimation::createWithFile("spineboy.json", "spineboy.atlas");
skeletonNode->setAnimation("walk", true);
skeletonNode->setPosition(ccp(300,0));
//skeletonNode->debugSlots = true;
skeletonNode->debugBones = true;
skeletonNode->timeScale = 0.5f;
addChild(skeletonNode,0,1);
ParticleSun* _emitter1 = ParticleSun::create();
_emitter1->setTexture( TextureCache::getInstance()->addImage("fire.png") );
addChild(_emitter1, 10, 2);
ParticleGalaxy* _emitter2 = ParticleGalaxy::create();
_emitter2->setTexture( TextureCache::getInstance()->addImage("fire.png") );
skeletonNode->addChild(_emitter2, 10, 20);
scheduleUpdate();
return true;
}
//update
void HelloWorld::update (float deltaTime)
{
CCSkeletonAnimation* skeletonNode = (CCSkeletonAnimation*)getChildByTag(1);
Bone* pBone = skeletonNode->findBone("left hand");
CCPoint pt = skeletonNode->convertToWorldSpace(ccp(pBone->worldX,pBone->worldY));//粒子1是添加在Scene上的 所以需要坐标转换一下
ParticleSun* _emitter1 = (ParticleSun*)getChildByTag(2);
_emitter1->setPosition(pt);
pBone = skeletonNode->findBone("right hand");
pt = ccp(pBone->worldX,pBone->worldY);//粒子2直接挂到骨骼动画上,所以不需要转换坐标
ParticleGalaxy* _emitter2 = (ParticleGalaxy*)skeletonNode->getChildByTag(20);
_emitter2->setPosition(pt);
}
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
CCSkeletonAnimation* skeletonNode = CCSkeletonAnimation::createWithFile("spineboy.json", "spineboy.atlas");
skeletonNode->setAnimation("walk", true);
skeletonNode->setPosition(ccp(300,0));
//skeletonNode->debugSlots = true;
skeletonNode->debugBones = true;
skeletonNode->timeScale = 0.5f;
addChild(skeletonNode,0,1);
ParticleSun* _emitter1 = ParticleSun::create();
_emitter1->setTexture( TextureCache::getInstance()->addImage("fire.png") );
addChild(_emitter1, 10, 2);
ParticleGalaxy* _emitter2 = ParticleGalaxy::create();
_emitter2->setTexture( TextureCache::getInstance()->addImage("fire.png") );
skeletonNode->addChild(_emitter2, 10, 20);
scheduleUpdate();
return true;
}
//update
void HelloWorld::update (float deltaTime)
{
CCSkeletonAnimation* skeletonNode = (CCSkeletonAnimation*)getChildByTag(1);
Bone* pBone = skeletonNode->findBone("left hand");
CCPoint pt = skeletonNode->convertToWorldSpace(ccp(pBone->worldX,pBone->worldY));//粒子1是添加在Scene上的 所以需要坐标转换一下
ParticleSun* _emitter1 = (ParticleSun*)getChildByTag(2);
_emitter1->setPosition(pt);
pBone = skeletonNode->findBone("right hand");
pt = ccp(pBone->worldX,pBone->worldY);//粒子2直接挂到骨骼动画上,所以不需要转换坐标
ParticleGalaxy* _emitter2 = (ParticleGalaxy*)skeletonNode->getChildByTag(20);
_emitter2->setPosition(pt);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询