CCParticleSystem* CCParticleSystem::createWithTotalParticles(unsigned int numberOfParticles) { CCParticleSystem *pRet = new CCParticleSystem(); if (pRet && pRet->initWithTotalParticles(numberOfParticles)) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return pRet; }
void TestParticle::initRotFlower() { CCParticleSystem *emitter = new CCParticleSystemQuad(); emitter->initWithTotalParticles(300); //emitter->autorelease(); addChild(emitter); ////emitter->release(); // win32 : Remove this line emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage("stars2.png")); // duration emitter->setDuration(-1); // gravity emitter->setGravity(CCPointZero); // angle emitter->setAngle(90); emitter->setAngleVar(360); emitter->setSpeed(160); emitter->setSpeedVar(20); // radial emitter->setRadialAccel(-120); emitter->setRadialAccelVar(0); // tagential emitter->setTangentialAccel(30); emitter->setTangentialAccelVar(0); // emitter position emitter->setPosition( ccp(160,240) ); emitter->setPosVar(CCPointZero); // life of particles emitter->setLife(3); emitter->setLifeVar(1); // spin of particles emitter->setStartSpin(0); emitter->setStartSpinVar(0); emitter->setEndSpin(0); emitter->setEndSpinVar(2000); ccColor4F startColor = {0.5f, 0.5f, 0.5f, 1.0f}; emitter->setStartColor(startColor); ccColor4F startColorVar = {0.5f, 0.5f, 0.5f, 1.0f}; emitter->setStartColorVar(startColorVar); ccColor4F endColor = {0.1f, 0.1f, 0.1f, 0.2f}; emitter->setEndColor(endColor); ccColor4F endColorVar = {0.1f, 0.1f, 0.1f, 0.2f}; emitter->setEndColorVar(endColorVar); // size, in pixels emitter->setStartSize(30.0f); emitter->setStartSizeVar(00.0f); emitter->setEndSize(kParticleStartSizeEqualToEndSize); // emits per second emitter->setEmissionRate(emitter->getTotalParticles()/emitter->getLife()); // additive emitter->setBlendAdditive(false); emitter->setPosition(ccp(size.width/6*5,size.height-250)); emitter->release(); }
void ParticleMainScene::createParticleSystem() { CCParticleSystem *particleSystem = NULL; /* * Tests: * 1: Point Particle System using 32-bit textures (PNG) * 2: Point Particle System using 16-bit textures (PNG) * 3: Point Particle System using 8-bit textures (PNG) * 4: Point Particle System using 4-bit textures (PVRTC) * 5: Quad Particle System using 32-bit textures (PNG) * 6: Quad Particle System using 16-bit textures (PNG) * 7: Quad Particle System using 8-bit textures (PNG) * 8: Quad Particle System using 4-bit textures (PVRTC) */ removeChildByTag(kTagParticleSystem, true); // remove the "fire.png" from the TextureCache cache. CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"); CCTextureCache::sharedTextureCache()->removeTexture(texture); //TODO: if (subtestNumber <= 3) // { // particleSystem = new CCParticleSystemPoint(); // } // else { particleSystem = new CCParticleSystemQuad(); } switch( subtestNumber) { case 1: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); break; case 2: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); break; case 3: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); break; // case 4: // particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.pvr"]; // particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); // break; case 4: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); break; case 5: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); break; case 6: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); break; // case 8: // particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.pvr"]; // particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); // break; default: particleSystem = NULL; CCLOG("Shall not happen!"); break; } addChild(particleSystem, 0, kTagParticleSystem); particleSystem->release(); doTest(); // restore the default pixel format CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); }