//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);