标签:
spine骨骼加载粒子效果 将粒子效果加到骨骼上,update位置和角度
.h
#ifndef __HOMESCENE_H__
#define __HOMESCENE_H__
#include "cocos2d.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
#include <spine/spine-cocos2dx.h>
#include "spine/spine.h"
using namespace spine;
using namespace cocostudio::timeline;
USING_NS_CC;
class HomeScene : public cocos2d::Scene
{
public :
HomeScene();
virtual ~HomeScene();
public :
void initUI();
void update(float);
public:
ParticleSystemQuad* emitter;
SkeletonAnimation* spineNode1;
ui::Layout* homeLayout;
};
#endif
.cpp
void HomeScene::initUI()
{
Node* root_node = CSLoader::createNode("homeScene.csb");
homeLayout = static_cast<ui::Layout*>(root_node->getChildByName("Panel_Home"));
spineNode1 = SkeletonAnimation::createWithFile("Boss01.json", "Boss01.atlas");
spineNode1->setAnimation(0, "ATK", true);
spineNode1->setPosition(Vec2(568, 200));
homeLayout->addChild(spineNode1);
emitter = ParticleSystemQuad::create("Eff_BG01_2.plist");
homeLayout->addChild(emitter, 0, 1);
this->scheduleUpdate();
}
void HomeScene::update(float dt)
{
spBone* particleBone = spineNode1->findBone("Boss06_weapon01");
Vec2 bonePos = Vec2(particleBone->worldX, particleBone->worldY);
Vec2 pt = spineNode1->convertToWorldSpace(bonePos);//粒子1是添加在Scene上的 所以需要坐标转换一下
emitter->setPosition(pt);
emitter->setRotation(particleBone->worldRotation);
}
标签:
原文地址:http://www.cnblogs.com/caoguoping100/p/4243743.html