Cocos2d-x3.1 粒子效果演示样例[通俗易懂]

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

效果图:

Cocos2d-x3.1 粒子效果演示样例[通俗易懂]

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/116622.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • 中兴新支点Linux国产操作系统安装windows字体的方法「建议收藏」

    中兴新支点操作系统是一款非常好用易上手的国产操作系统,重易用体验和美观设计,因此对于大多数用户来说,它易用安装和使用,还能够很好的代替Windows系统进行工作与娱乐。用Windows的用户都知道,在使用过程中经常要用到各种字体,那中兴新支点国产操作系统如何安装这些字体呢,小编给大家整理了下面的教程。第一步:将Windows下喜欢的字体文件copy到一个文件夹中,例如将Windows…

  • 肝了一晚帮她搭建完个人网站——利用Docker在单节点上实现内外网隔离网站部署(Nginx、WordPress、MySQL)

    肝了一晚帮她搭建完个人网站——利用Docker在单节点上实现内外网隔离网站部署(Nginx、Wordpress、MySQL)目录1、前言2、注册3、重置服务器实例密码4、配置安全规则5、登录服务器6、更新系统7、安装Docker8、创建Docker子网络9、创建子网内的MySQL实例10、创建子网内的WordPress实例11、创建Nginx反向代理实例12、查看状态13、配置WordPress14、发布站点15、访问站点16、Docker命令行日常更新18、总结1、前言  同事小姐姐琦琦毕业后就应聘来到我们公司做项目助理,跟我分在一个项目组。琦琦自身先天条件就很好,长得耐看,身高1.65,偏瘦,整体算中等偏上的水平吧。她平

  • shell训练营 Day6「建议收藏」

    shell训练营 Day6「建议收藏」shell训练营 Day6

  • BYTE 和 COleVariant 相互转换

    BYTE 和 COleVariant 相互转换#include     BOOL GetBinaryFromVariant(COleVariant & ovData, BYTE ** ppBuf, unsigned long * pcBufLen)  {    BOOL fRetVal = FALSE;      //Binary data is stored in the variant as an array of

  • 量化投资资源

    量化投资资源有些国外的平台、社区、博客如果连接无法打开,那说明可能需要“科学”上网1、量化交易平台国内在线量化平台:BigQuant-你的人工智能量化平台-可以无门槛地使用机器学习、人工智能开发量化策略,基于python,提供策略自动生成器镭矿-基于量化回测平台果仁网-回测量化平台京东量化-算法交易和量化回测平台聚宽-量化回测平台优矿-通联量化实验室Ricequ…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号