码迷,mamicode.com
首页 > 其他好文 > 详细

cocos2d-x spine 加载粒子特效

时间:2015-01-23 12:51:13      阅读:528      评论:0      收藏:0      [点我收藏+]

标签:

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);
}

cocos2d-x spine 加载粒子特效

标签:

原文地址:http://www.cnblogs.com/caoguoping100/p/4243743.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!