Multiple explosions with same particle system

Right now, every time there are explosions in my game, I am running the following code:

void GameLayer::emitExplosion(const Point& point) {
  auto emitter = ParticleSystemQuad::create("Particles/Explosion.plist");
  emitter->setPosition(point);
  emitter->setAutoRemoveOnFinish(true);

  addChild(emitter, 10);
}

Does that mean that for every explosion I am reading the plist file? Is there a way to optimize this, so that the emitter only gets created once?

Take into account that there may be multiple explosions at the same time on the screen…

take a look at what i’ve done for EarthWarrior3D

I had the same problem you encountered, each time a particle system is “created”, it reads the plist, parse xml, and worse if you embedded your texture in plist, it will try to decode it every-time, which is stupid

what i did was adding 2 more creates for particle system, that let it accept a valuemap, a valuemap is the result dictionary after reading a plist file, so I pre-parse all the plist file to valuemaps, so each time a particle system is created, it reads from the cached valuemap instead of the plist.

another thing i did was I get the texture from a sprite atlas for the particle system,

here is the code in action

auto fileUtil = FileUtils::getInstance();
auto plistData = fileUtil->getValueMapFromFile("vanishingPoint.plist");
auto sf = SpriteFrame::create("bullets.png", Rect(5,8,24,32));
auto stars = ParticleSystemQuad::create(plistData, sf);
//or if you don't need sprite frame
auto stars = ParticleSystemQuad::create(plistData);

Ah, nice ideas! Thank you very much!