I had a look at your example project.
There seems to be some problem with the way Cocos2D is managing the actions. After some testing, it's clear that some actions are simply not being triggered by the
Cocos2D action manager. It could be a function of how frequently you are adding actions. I'm not sure.
You might have to manage the removals manually. Here's one suggestion:
- Create a custom
CCPlaneNode subclass (e.g..
SplashNode) that can keep track of how long an instance has been alive.
- Create each splash node using this class.
- Hold the splash nodes in an array so you can quickly iterate over them.
- In your
updateBeforeTransform: method, iterate over the existing splash nodes, and increment the lifetime value for each node, and for any that have lived long enough, remove them from both the scene (using
visitor requestRemovalOf:), and the iteration array (which you will have to do after the array iteration to avoid iteration conflicts).
This design won't cost any additional performance, because the actions are fired within Cocos2D by adding, iterating, and removing actions within arrays anyway.
If you want to get fancy (and I would probably do it this way), you can also create as subclass of
CC3Node that holds all the splashes as child nodes, add that node to the scene, and then add the splashes as children of that node, instead of adding the splashes directly to the scene. That would eliminate the need for a separate splash-tracking array, because you could just write the
updateBeforeTransform: method of the splash-holder node to iterate through all its children (which would all be
SplashNodes) to perform the logic above.
One further comment...
Instead of creating and configuring each splash node from scratch (as you are currently doing), you can improve efficiency by creating one splash node as a template, and then simply using the
copy method to create a copy of that template whenever you need to add a new splash. By using copies, each new node will automatically be configured the same as the template, including mesh, texture, and shaders (saving some setup time for each node), and the actual mesh vertices will be shared between the nodes, saving some memory.