Cocos2D-X入門(6)粒子系統

來源:互聯網
上載者:User

第一種方法:自訂

//建立一個粒子系統  CCParticleSystem* pParticleSystem=new CCParticleSystemQuad();  //產生300個粒子  pParticleSystem->initWithTotalParticles(300);  //設定粒子圖片  pParticleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("yezi.png"));  //設定粒子系統期間  pParticleSystem->setDuration(-1);  //設定重力方向  pParticleSystem->setGravity(CCPointZero);  //設定角度,角度變動率  pParticleSystem->setAngle(0);  pParticleSystem->setAngleVar(360);  //設定運動速度,運動速度的變動率  pParticleSystem->setSpeed(50);  pParticleSystem->setSpeedVar(10);  //設定徑向加速度,徑向加速度的變動率  pParticleSystem->setRadialAccel(70);  pParticleSystem->setRadialAccelVar(10);  //設定切向加速度,徑向加速度的變動率  pParticleSystem->setTangentialAccel(80);  pParticleSystem->setTangentialAccelVar(0);  //設定粒子初始位置,位置變動率  pParticleSystem->setPosition(mSize.width/2,mSize.height/2);  pParticleSystem->setPosVar(ccp(100,100));  //設定粒子存在時間,時間變動率  pParticleSystem->setLife(2);  pParticleSystem->setLifeVar(0.3);  //設定粒子初始顏色,顏色變動率  ccColor4F cccStart={0.5,0.5,0.5,1.0};  pParticleSystem->setStartColor(cccStart);  pParticleSystem->setStartColorVar(cccStart);  //設定粒子結束顏色,顏色變動率  ccColor4F cccEnd={0.5,0.5,0.5,1.0};  pParticleSystem->setStartColor(cccEnd);  pParticleSystem->setStartColorVar(cccEnd);  //設定粒子初始大小,大小變動率  pParticleSystem->setStartSize(10);  pParticleSystem->setStartSizeVar(20);  //設定粒子結束大小,大小變動率  pParticleSystem->setStartSize(12);  pParticleSystem->setStartSizeVar(12);  //設定每秒產生粒子數  pParticleSystem->setEmissionRate(pParticleSystem->getTotalParticles()/pParticleSystem->getLife());        this->addChild(pParticleSystem,1);

效果圖:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.