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)
上一篇 2022年1月18日 下午2:00
下一篇 2022年1月18日 下午2:00


相关推荐

  • webstorm激活码(注册激活)

    (webstorm激活码)JetBrains旗下有多款编译器工具(如:IntelliJ、WebStorm、PyCharm等)在各编程领域几乎都占据了垄断地位。建立在开源IntelliJ平台之上,过去15年以来,JetBrains一直在不断发展和完善这个平台。这个平台可以针对您的开发工作流进行微调并且能够提供…

    2022年3月28日
    199
  • 常量指针和指针常量的详解一样吗_指针是常量还是变量

    常量指针和指针常量的详解一样吗_指针是常量还是变量说一下常量指针和指针常量的区别。常量指针  指向常量的指针,也就是说指针指向的对象是常量,指向的常量不能修改。指针不是一个常量,可以把指针指向别一个常量。常量指针是我们最常用的,一般声明形式如下:constint*p;intconst*p;例:inta=1,b=2;constint*p;//或者是intconst*p;p=&…

    2022年10月21日
    5
  • SpringBoot 缓存之 @Cacheable 详细介绍

    SpringBoot 缓存之 @Cacheable 详细介绍一 简介 1 缓存介绍 Spring 从 3 1 开始就引入了对 Cache 的支持 定义了 org springframew cache Cache 和 org springframew cache CacheManager 接口来统一不同的缓存技术 并支持使用 JCache JSR 107 注解简化我们的开发 其使用方法和原理都类似于 Spring 对事务管理的支持 SpringCache 是作用在方法上的 其核心思想是 当我们在调用一个缓存方法时会把该方法参数和返回结果作为一个

    2026年3月20日
    2
  • 开源中国招聘新增两大功能,让你的声音更有影响力[通俗易懂]

    开源中国招聘新增两大功能,让你的声音更有影响力

    2022年3月4日
    42
  • Vuethink正确安装过程

    Vuethink正确安装过程

    2021年10月13日
    42
  • ubuntu 18.04安装edge浏览器

    ubuntu 18.04安装edge浏览器1.先下载适用于Ubuntu的deb格式安装包2.使用sudodpkg-imicrosoft-edge-dev_****_amd64.deb,安装edge3.安装后会发现打不开,运行以下代码sudoaptinstallmicrosoft-edge-dev4.运行sudoaptinstallmicrosoft-edge-dev后,会出现错误:Unmetdependencies.Try’apt–fix-brokeninstall’withn…

    2022年7月21日
    18

发表回复

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

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