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

6 cocos2dx粒子效果,类图关系,系统原生粒子和自定义粒子效果,粒子编译器软件,爆炸粒子效果,烟花效果,火焰效果,流星效果,漩涡粒子效果,雪花效果,烟雾效果,太阳效果,下雨效果

时间:2014-10-30 15:25:46      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   os   ar   sp   文件   



1 粒子

示例

bubuko.com,布布扣

2 类图关系

bubuko.com,布布扣

3 系统原生粒子

CCParticleSystem

所有粒子系统的父类

CCParticleSystemPoint

CCParticleSystemQuad

点粒子和方形粒子系统,都继承了CCParticleSystem的所有属性

CCParticleExplosion

爆炸粒子效果

CCParticleFireworks

烟花粒子效果

CCParticleFire

火焰粒子效果

CCParticleMetepr

流行粒子效果

CCParticleSpiral

漩涡粒子效果

CCParticleSnow

雪粒子效果

CCParticleSmoke

烟粒子效果

CCParticleSun

太阳粒子效果

CCParticleRain

雨粒子效果

4 代码

//CCParticleExplosion * particle = CCParticleExplosion::create();

//CCParticleFireworks * particle = CCParticleFireworks::create();

//CCParticleFire * particle = CCParticleFire::create();

//CCParticleMeteor * particle = CCParticleMeteor::create();

//CCParticleSpiral * particle = CCParticleSpiral::create();

//CCParticleSnow * particle = CCParticleSnow::create();

//CCParticleSmoke * particle = CCParticleSmoke::create();

//CCParticleSun * particle = CCParticleSun::create();

CCParticleRain * particle = CCParticleRain::create();

 

particle->setPosition(ccp(240, 160));

addChild(particle);

5 手动制作粒子系统

粒子编译器软件

bubuko.com,布布扣

编辑好后生成xx.plist文件

CCParticleSystemQuad * particle = CCParticleSystemQuad::create("ring.plist");

particle->setPosition(ccp(240, 160));

addChild(particle);

particle->setDuration(4);

6 案例

爆炸粒子效果

T21Particle.h

#ifndef __T12Particle_H__

#define __T12Particle_H__

#include "cocos2d.h"

#include "TBack.h"

USING_NS_CC;

class T21Particle :public TBack

{

public:

    static CCScene * scene();

    CREATE_FUNC(T21Particle);

    bool init();

 

};

 

#endif

T21Particle.cpp

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //爆炸粒子效果

    CCParticleExplosion * particle = CCParticleExplosion::create();

   

    addChild(particle);

   

    return true;

}

运行效果:

bubuko.com,布布扣

烟花效果

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //烟花效果

    CCParticleFireworks * particle = CCParticleFireworks::create();

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height / 4));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

运行结果:

bubuko.com,布布扣

火焰效果:

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //火焰效果

    CCParticleFire * particle = CCParticleFire::create();

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height / 4));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

bubuko.com,布布扣

流星效果:

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //流星粒子效果

    CCParticleMeteor * particle = CCParticleMeteor::create();

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height / 4));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

运行效果:

bubuko.com,布布扣

漩涡粒子效果

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //流行粒子效果

    CCParticleSpiral * particle = CCParticleSpiral::create();

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height / 4));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

运行效果:

bubuko.com,布布扣

雪花效果:

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //雪花效果

    CCParticleSnow * particle = CCParticleSnow::create();

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

运行效果:

bubuko.com,布布扣

烟雾效果:

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //烟雾效果

    CCParticleSmoke * particle = CCParticleSmoke::create();

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height/3));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

运行结果:

bubuko.com,布布扣

太阳效果

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //太阳效果

    CCParticleSun * particle = CCParticleSun::create();

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height/3));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

运行效果:

bubuko.com,布布扣

下雨效果

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    //细雨效果

    CCParticleRain * particle = CCParticleRain::create();

    //particle->setRotation(90);

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

运行结果:

bubuko.com,布布扣

7 通过自定义的.plist文件作出粒子效果

案例:

环形效果

#include "T21Particle.h"

#include "AppMacros.h"

 

CCScene * T21Particle::scene()

{

    CCScene * scene = CCScene::create();

    T21Particle * layer = T21Particle::create();

    scene->addChild(layer);

    return scene;

}

 

bool T21Particle::init()

{

    TBack::init();

   

    CCParticleSystemQuad * particle = CCParticleSystemQuad::create("ring.plist");

   

    //设置位置显示位置

    particle->setPosition(ccp(winSize.width / 2,winSize.height / 2));

    //设置时间间隔

    particle->setDuration(20);

    addChild(particle);

   

    return true;

}

运行结果:

bubuko.com,布布扣

bubuko.com,布布扣

 

6 cocos2dx粒子效果,类图关系,系统原生粒子和自定义粒子效果,粒子编译器软件,爆炸粒子效果,烟花效果,火焰效果,流星效果,漩涡粒子效果,雪花效果,烟雾效果,太阳效果,下雨效果

标签:style   blog   http   io   color   os   ar   sp   文件   

原文地址:http://blog.csdn.net/tototuzuoquan/article/details/40618909

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