zoukankan      html  css  js  c++  java
  • cocos2d-x 3.1.1 学习笔记[16] Particle 粒子效果

        //plist文件中面有粒子效果的各种參数
        //textureFileName相应着使用粒子的图片
        auto particle = ParticleSystemQuad::create("starFlash.plist");
        particle->setPosition(Vec2(s.width / 2, s.height / 2));
        addChild(particle);
        
        
        //全部的配置也能够自己写
        auto p2 = ParticleSystemQuad::createWithTotalParticles(200);
        p2->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseNormal.png"));
        p2->setPosition(Vec2(100, 100));
        // duration
        p2->setDuration(ParticleSystem::DURATION_INFINITY);
        
        // radius mode
        p2->setEmitterMode(ParticleSystem::Mode::RADIUS);
        
        // radius mode: start and end radius in pixels
        p2->setStartRadius(4);
        p2->setStartRadiusVar(1);
        p2->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
        p2->setEndRadiusVar(0);
        
        // radius mode: degrees per second
        p2->setRotatePerSecond(100);
        p2->setRotatePerSecondVar(0);
        
        // angle
        p2->setAngle(90);
        p2->setAngleVar(0);
        
        // emitter position
        auto size = Director::getInstance()->getWinSize();
        p2->setPosVar(Point::ZERO);
        
        // life of particles
        p2->setLife(0.5);
        p2->setLifeVar(0);
        
        // spin of particles
        p2->setStartSpin(0);
        p2->setStartSpinVar(0);
        p2->setEndSpin(0);
        p2->setEndSpinVar(0);
        
        // color of particles
        Color4F startColor(0.0f, 0.8f, 0.9f, 1.0f);
        p2->setStartColor(startColor);
        
        Color4F startColorVar(0, 0, 0, 1.0f);
        p2->setStartColorVar(startColorVar);
        
        Color4F endColor(1.0f, 1.0f, 1.0f, 0.1f);
        p2->setEndColor(endColor);
        
        Color4F endColorVar(0, 0, 0, 0.1f);
        p2->setEndColorVar(endColorVar);
        
        // size, in pixels
        p2->setStartSize(20);
        p2->setStartSizeVar(1);
        p2->setEndSize(0);
        
        // emits per second
        p2->setEmissionRate(p2->getTotalParticles() / p2->getLife());
        
        // additive
        p2->setBlendAdditive(false);
        
        //addChild(p2);
        p2->setPosition(Point(200,200));
        addChild(p2);
    













  • 相关阅读:
    Bulk insert的用法
    跨服务器与连接不同数据库 不跨服务器连接库存表
    读书笔记(1)
    CSS渲染HTML时的优先级问题
    如何使用as3获得一组不重复的随机数
    flash cs5导出swc到flash builder 4
    转:AS3.0的Dictionary类简介
    转:As3.0中的反射
    Flex 4里的fx、mx以及s命名空间
    yahoo的flash组件
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/7111654.html
Copyright © 2011-2022 走看看