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 粒子效果演示样例[通俗易懂]

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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 「建议收藏」Pycharm使用教程(非常详细,非常实用)「建议收藏」

    「建议收藏」Pycharm使用教程(非常详细,非常实用)「建议收藏」Pycharm使用教程1、Jetbrains家族和Pycharm版本划分:pycharm是Jetbrains家族中的一个明星产品,Jetbrains开发了许多好用的编辑器,包括Java编辑器(IntelliJIDEA)、JavaScript编辑器(WebStorm)、PHP编辑器(PHPStorm)、Ruby编辑器(RubyMine)、C和C++编辑器(CLion)、.Net编辑器(Rider)、iOS/macOS编辑器(AppCode)等。pycharm现在在官网[https://www.jetb

    2022年8月25日
    5
  • 【JavaScript】想在JS中使用换行符,我该怎么操作呢?

    【JavaScript】想在JS中使用换行符,我该怎么操作呢?使用’\n’换行,而不是’\n’注意前后空格实战demo:$(‘#text’).val(‘hello’+’\n’+’world’);

    2022年5月10日
    36
  • word在试图打开文件时遇到错误,检查稳定或驱动器文件权限

    word在试图打开文件时遇到错误,检查稳定或驱动器文件权限查网上说属性—解除锁定,就好了我看很多人也是这问题,这种方案就可以解决。但我的是根本就没有“解除锁定”这一选项。我用的是2013版的word,但可以用office2010打开(我电脑上安装了两个office版本)。而且在其它电脑上office2013可以打开。我的解决方案是用office2010打开后把昨天写的部分删除,发现用office2013可以打开了。然后再从201…

    2022年5月10日
    97
  • msm8937之I2C配置

    msm8937之I2C配置msm8937.dtsi中aliases{i2c1=&i2c_1;i2c2=&i2c_2;i2c3=&i2c_3;i2c4=&i2c_4;i2c5=&i2c_5;i2c6=&i2c_6;i…

    2022年10月18日
    2
  • select top 1 * from tablename[通俗易懂]

    select top 1 * from tablename[通俗易懂]今天在网上查找selecttop1*fromDepartMent的信息时,找到的信息答案不是很准确所以现在把自己的答案张贴出来。希望对大家有所帮助。selecttop1*fromtablename这段SQL语句的意思是:读取一个表中的第一条记录。如果是selecttop 5*fromtablename这样的话呢就是读取表中记录的前5条记录。  

    2022年7月15日
    16
  • Wappalyzer 网站技术分析软件「建议收藏」

    Wappalyzer 网站技术分析软件「建议收藏」Wappalyzer工具支持分析目标网站所采用的平台构架、网站环境、服务器配置环境、JavaScript框架、编程语言等参数,同时还可以显示目标站点使用该技术的网站比例,例如有多少网站使用的是Wordpress、有多少网站使用AddThis第三方服务,其他还有网页服务器、分析工具、CDN、留言系统、控制台、网络空间等等,可以让你从使用比例中得出目前最流行的技术。使用方法:1.打开

    2022年5月12日
    77

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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