views:

338

answers:

3

Hi all,

I need to create a particle system and retain the created particles. I need to shake / move the created particles with the iphone accelerometer. Also, the number of particles needs to be very high (I need to show sand!).

I do not have any OpenGLES programming experience.

After initial search, I found Cocos2D can be used for particle generation. But there is no way of retaining the particles in the CCParticle system. As a work around, I tried creating many sprites at the end of particle generation and shown them as particles. But moving few number of sprites with accelerometer drops the frame rate considerably.

Please suggest how this can be achieved and whether I should look for some other framework or if some kind of similar demo code is available.

Thanks, Swapnil

+3  A: 

Here you go, iphoneparticles, an open source particle generator in OpenGL ES for iPhone. Check out the source code if you want to get an idea about how it was made.

Also, you may want to take a look at the source code of the demo app presented in this article. It uses a Particle Emitter class created by 71 Squared.

luvieere
thanks for the quick reply luvieere. Downloaded both the source codes. They are similar to the particle engine tests in cocos2d. But my main problem is with retaining the particles. I will still thoroughly look into the downloaded codes and see if i can manage to retain the particles from these systems.
lukya
+1  A: 

Take a look at CAReplicatorLayer, which lets you use Core Animation to create nice particle systems. Apple has a good example of this for the Mac, which I ported to the iPad.

Brad Larson
+1  A: 

Hi again!!

Tried all the mentioned approaches but none suits what i'm trying to achieve.

Things are ok as long as i create particles. But the moment i start using them as sprites (or create new sprite as particles disappear) and move them with accelerometer the performance is really really bad as the number of sand particles is huge.

So here is a work around i am going to try:

Create a huge sprite sheet with each sprite of size 320 * 480, showing sand scattered in different positions/directions, and change the sprites according to accelerometer inputs.

I know this sound like a lame work around but i created a small sprite sheet POC and it is not so bad.

Please let me know if you think this workaround is somehow flawed or i should be using some other approach.

Thanks, Swapnil

lukya