标签:style blog http io color os ar 使用 sp
参考文章:
http://www.cnblogs.com/shangdahao/archive/2012/04/14/2447571.html
http://blog.csdn.net/ganpengjin1/article/details/18554225
http://blog.csdn.net/aa4790139/article/details/8124781
一、什么是粒子系统
二、Particle Editor的使用
网络上有很多教程讲解怎么下载使用Particle Editor。这里就不多说了。
三、Cocos2d-x对对粒子系统的实现
其实对于cocos2dx中的粒子系统而言,一切都已经模板化了。照猫画虎就行了。主要是对粒子系统中参数的配置调整。下面说说cocos2dx中对粒子系统的支持实现
(1)利用cocos2dx已经打包好的粒子系统参数效果:
CCParticleExplosion爆炸
CCParticleFire 火
CCParticleFireworks烟火
CCParticleFlower花
CCParticleGalaxy 银河
CCParticleMeteor 流行
CCParticleRain 下雨
CCParticleSmoke 下雪
CCParticleSnow 炊烟
CCParticleSpiral 螺旋
CCParticleSun 太阳焰
例如:
CCParticleSystem* m_emitter; m_emitter = CCParticleFireworks::node(); m_emitter->retain(); this->addChild(m_emitter, 10); m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(“image.png”) ); m_emitter->setPosition(ccp(489,320));
(2)利用Particle Editor编辑参数
通过这种方法我们会用到下面两个方法,导入生成的(*.plist)文件
bool initWithFile(const char *plistFile) static CCParticleSystem* create(const char *plistFile)
例如:
CCParticleSystemQuad *system = new CCParticleSystemQuad(); system->initWithFile("Images/SpinningPeas.plist");//plist文件可以通过例子编辑器获得 system->setTextureWithRect(CCTextureCache::sharedTextureCache()->addImage("Images/particles.png") , CCRectMake(0,0,32,32)); addChild(system, 10); system->setPosition
(3)利用代码配置粒子系统参数
CCParticleSystem* m_emitter; m_emitter = new CCParticleSystemQuad(); m_emitter->initWithTotalParticles(50); this->addChild(m_emitter, 10); m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_stars1) ); m_emitter->setDuration(-1); // gravity m_emitter->setGravity(CCPointZero); // angle m_emitter->setAngle(90); m_emitter->setAngleVar(360); // speed of particles m_emitter->setSpeed(160); m_emitter->setSpeedVar(20); // radial m_emitter->setRadialAccel(-120); m_emitter->setRadialAccelVar(0); // tagential m_emitter->setTangentialAccel(30); m_emitter->setTangentialAccelVar(0); // emitter position m_emitter->setPosition( CCPointMake(160,240) ); m_emitter->setPosVar(CCPointZero); // life of particles m_emitter->setLife(4); m_emitter->setLifeVar(1); // spin of particles m_emitter->setStartSpin(0); m_emitter->setStartSizeVar(0); m_emitter->setEndSpin(0); m_emitter->setEndSpinVar(0); // color of particles ccColor4F startColor = {0.5f, 0.5f, 0.5f, 1.0f}; m_emitter->setStartColor(startColor); ccColor4F startColorVar = {0.5f, 0.5f, 0.5f, 1.0f}; m_emitter->setStartColorVar(startColorVar); ccColor4F endColor = {0.1f, 0.1f, 0.1f, 0.2f}; m_emitter->setEndColor(endColor); ccColor4F endColorVar = {0.1f, 0.1f, 0.1f, 0.2f}; m_emitter->setEndColorVar(endColorVar); // size, in pixels m_emitter->setStartSize(80.0f); m_emitter->setStartSizeVar(40.0f); m_emitter->setEndSize(kParticleStartSizeEqualToEndSize); // emits per second m_emitter->setEmissionRate(m_emitter->getTotalParticles()/m_emitter->getLife()); // additive m_emitter->setIsBlendAdditive(true);
标签:style blog http io color os ar 使用 sp
原文地址:http://blog.csdn.net/discoveryunknown/article/details/40506991