0
votes

Hey guys and girls. I have a method that creates rain particles, tiny images, of CCSprite class type. Everything is working well, when the clouds rain, they rain many particles of CCSprites until they leave the vertical winsize space.. Once they do leave the vertical winsize space, the iphone simulator begins to lag as it removes each rain CCSprite.

I think the problem is that their are so many CCsprites to remove, not the actual demand of having them in the memory.

My method to remove sprites is called 60 times per second. I tried perhaps changing the frequency of deletion to 1/1second, but to no avail, its made it more laggy because theres more sprites to delete at once...

How could I go about fixing this problem, or am i using CCsprite ineffectively, is there a better Class to use?

2
I have no experience in Cocos 2D so this might be an irrelevant question, but are you sure that you are reusing CCSprite objects? If you are reusing them and the total size is not destructive as you say, you may just keep them alive. - MHC
I wasnt reusing the sprites. When the cloud rains, it creates about 60 rain particles - each an individual ccsprite. I just read this thread: stackoverflow.com/questions/4296542/… It has a good explanation to 'reuse' these sprites rather than deleting and recreating them every time the cloud rains (approx every 2 seconds). - Ospho
Can't you just move the sprites back up to the top after it falls through the bottom of the view? That way you don't need to alloc and release so many ccsprites. - futureelite7

2 Answers

1
votes

There is a particle example.. which is rain particle..

call the function 30 times per second.. i am not sure why removing would lag..

0
votes

To simulate rain take a look at particle effects in cocos2d (there is a rain example). It should be more effective and much more easy to create and use.