Thanks for the replies.
Yes I need to be able to address all the instances individually or in some cases they could be addressed sequentially as they were created. I will try these suggestions out..
I'm trying to work out a methodology for creating object instances that have a corresponding CCSprite object associated with them.
For example I might have a "ball" class that needs to contain 5 ball objects, and each of those 5 ball object are associated with a unique CCSprite. Say a CCSprite of a Baseball, Basketball, Soccerball, Football, Softball (5 textures all within the same SpriteSheet).
In another case, I might have a different "ball" class that contain 20 ball object, all of which use the same Soccerball, CCSprite texture.
I have read about using an "initwithimage" method within the ball class, but I have a situation where I cannot just add a non-CCSprite node to my GameScene class layer. The GameScene class layer has background art CCSprites that are batched (in a SpriteBatchNode) and on DIFFERENT Z Layers. I need to be able to insert my ball objects at specific Z Depths between the different backdrop art images.
The only way to do that, that I can figure out, is to add the ball objects as children to the GameScene batch node. A batch node will only accept CCSprites as children, it will not accept non-CCSprite class instance objects as children. Apparently, a batch node cannot be assigned as a child to another batch node either. You cannot nest batch nodes.
Therefore, if I create a ball instance using "initwithimage", that ball instance becomes a CCNode and cannot be added to a SpriteBatchNode (I get compiler errors stating this).
If the backdrop images are NOT BATCHED, and even if the ball Sprites are batched before creating instances with "initwithimage", the frame rate is unacceptably slow.. If I can draw the balls and backdrop images, in one batch, the frame rate only drops to about 58 or 59 fps at worst case.
I have tried to implement Steffan Itterhiem's "Bullet and Enemy class" type structures and they fail to work for my application. His methodology assumes you have a background layer and a UI Layer and your just sandwiching your game sprites in between those two layers by creating nodes to insert as new layers into the GameScene. My sprites need to intermingle between the Z depths of my background layer elements. If I draw each background image Sprite in a separate call (by NOT batching them and allowing his methodology to work) my frame rate becomes too slow and game sprite movement gets jerky and jittery.
Since I want to be able to individually manipulate ball objects within a GameScene class, but add them to a batch node withing the game scene class, I am trying to create a set of CCSprite objects, and then create a set of Ball instance objects (which contain logic code) which would control the CCSprite objects which are drawn to the screen via the GameScene class batch node.
If I don't find a solution soon, I will probably just create a single ball controller object instance, which will create the CCSprites, add them to the GameScene batch, then add them to a CCArray and cycle or pick and choose from the CCArray to address a particular ball and manipulate it. This way I get my Game Sprites added to the GameScene batch and Z-Layered properly. There will just be no ball objects or a ball object class.
Thinking about this makes my head hurt..