zoukankan      html  css  js  c++  java
  • Cocos2d-x3.1 粒子效果演示样例

    这里把粒子的几种效果粘出来,以便以后使用

    原文地址:http://blog.csdn.net/qqmcy/article/details/37511259

    //
    //  IntervalLayer.cpp
    //  testthirdone
    //
    //  Created by 杜甲 on 14-7-7.
    //
    //
    
    #include "IntervalLayer.h"
    
    #define SID_STEP1    100
    #define SID_STEP2    101
    #define SID_STEP3    102
    
    #define IDC_PAUSE    200
    
    bool IntervalLayer::init()
    {
        return true;
    }
    
    IntervalLayer::IntervalLayer()
    {
        _time0 = _time1 = _time2 = _time3 = _time4 = 0.0f;
        
        auto s = Director::getInstance()->getWinSize();
        
        auto sun = ParticleSun::create();
        sun->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        sun->setPosition(Vec2(s.width / 2 -100, s.height / 2));
        
        sun->setTotalParticles(130);
        sun->setLife(5.0f);
        
        this->addChild(sun);
        // timers
        
        
        auto fire = ParticleFire::create();
        fire->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        fire->setPosition(Vec2(s.width / 2 + 50, s.height / 2));
        
        fire->setTotalParticles(130);
        fire->setLife(5.0f);
        
        this->addChild(fire);
        
        auto fireworks = ParticleFireworks::create();
        fireworks->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        fireworks->setPosition(Vec2(s.width / 2 + 50, s.height / 2 - 200));
        
        fireworks->setTotalParticles(130);
        fireworks->setLife(5.0f);
        
        this->addChild(fireworks);
        
        
        auto galaxy = ParticleGalaxy::create();
        galaxy->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        galaxy->setPosition(Vec2( 50, s.height / 2 + 200));
        
        galaxy->setTotalParticles(130);
        galaxy->setLife(5.0f);
        
        this->addChild(galaxy);
        
        
    
        auto flower = ParticleFlower::create();
        flower->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        flower->setPosition(Vec2( 250, s.height / 2 + 200));
        
        flower->setTotalParticles(130);
        flower->setLife(5.0f);
        
        this->addChild(flower);
        
        //流星
        auto meteor = ParticleMeteor::create();
        meteor->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        meteor->setPosition(Vec2( 250, 20));
        
        meteor->setTotalParticles(130);
        meteor->setLife(5.0f);
        
        this->addChild(meteor);
        
        
        //旋涡
        auto spiral = ParticleSpiral::create();
        spiral->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        spiral->setPosition(Vec2( 450, 40));
        
        spiral->setTotalParticles(130);
        spiral->setLife(5.0f);
        
        this->addChild(spiral);
       
        //爆炸
        auto explosion = ParticleExplosion::create();
        explosion->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        explosion->setPosition(Vec2( 50, 440));
        
        explosion->setTotalParticles(130);
        explosion->setLife(5.0f);
        
        this->addChild(explosion);
        
        
        //烟雾
        auto smoke = ParticleSmoke::create();
        smoke->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        smoke->setPosition(Vec2( 450, 640));
        
        smoke->setTotalParticles(130);
        smoke->setLife(5.0f);
        
        this->addChild(smoke);
        
        //雪
        auto snow = ParticleSnow::create();
        snow->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        snow->setPosition(Vec2( 450, 840));
        
        snow->setTotalParticles(130);
        snow->setLife(5.0f);
        
        this->addChild(snow);
    
        //雨
        auto rain = ParticleRain::create();
        rain->setTexture(Director::getInstance()->getTextureCache()->addImage("fire.png"));
        rain->setPosition(Vec2( 450, 940));
        
        rain->setTotalParticles(130);
        rain->setLife(5.0f);
        
        this->addChild(rain);
        
        
        
    }

    效果图:


  • 相关阅读:
    百度地图定位经纬度返回4.9E-324有关问题
    急!JDBC问题,发生通信错误。错误位置:Reply.fill()。消息:数据不足。 ERRORCODE=-4499, SQLSTATE=08001
    Android 图片添加水印图片或者文字
    查询出多条记录,取最大或最小的某条件的记录,取唯一记录
    listView获取item的Edit内容,listView中的edit内容在滚动时自动赋值了前面的内容
    ListView中的item的按照和item点击事件并存
    update select
    db2 怎么计算两个时间相差多少个月。如2015-10-10 和2014-1-12
    解决AndroidADT自带Eclipse编辑器不能自动代码提示的问题
    python协程详解,gevent asyncio
  • 原文地址:https://www.cnblogs.com/yxwkf/p/5059396.html
Copyright © 2011-2022 走看看