I haven't found an embedded particle system yet,
There are several βfreeβ projects in which particle systems are built in. You can visit this video tutorial for a particle system that will be more than effective enough for the needs you are talking about. This way of creating a particle system is basically the same as using Cocos2d, so follow the tutorial and then upload the project files, you can easily insert your particle emitter into your project.
How can I use this memory efficiently?
I would recommend you use the Object Pool Pattern, "you basically define a pool of particles, say 1000 objects. Then your emitters, ask for a pool of particles when they need them. If the pool is empty, you can manage the case accordingly. It can seem inefficient in terms of memory, but it is very efficient performance (to avoid the real-time distribution of many small objects such as particles).
Some sentences, when you declare your particle structure, try to be light and aligned in degrees 2 (this will make your structure more cache friendly), this is 32 bytes:
struct Particle { CGPoint position; CGPoint speed; float life; float decay; unsigned short index; unsigned char color_R; unsigned char color_G; unsigned char color_B; unsigned char color_A; unsigned char rotation; };
But depending on your needs, it can be much less, maybe you do not need color / index / etc. You must evaluate it yourself.
Finally, I would recommend you take a look at the CCParticleSystem class, you can download the code here . Their implementation is not so easy, but rather flexible and can achieve very pleasant effects.
Good luck with your particles :)
Goles
source share