Question about batchnodes and gameobjects with multiple sprites

Question about batchnodes and gameobjects with multiple sprites
0.0 0


Hi everyone,

I’m developing a game, in which I have some characters made by multiple sprites. For example, the enemy class is a CCSprite initialized with the enemy’s body png and has some CCSprites to add additional body parts; like clothes face expresions, etc… Something like that:

My question is the following one: if I add the entire enemy class to the batchnode, I’m adding only the body sprite (the one used to initialize the class) or it automatically adds his children too? In other words; in the enemy class I have to add the children directly to the batchnode or it’s possible to do this->addChild(face,z); and after that add the entire enemy object into the batch?




It will add its children recursively for you.
You can refer to CCSpriteBatchNode::appendChild(CCSprite* sprite) for detail information.


Thanks Minggo,

I thought that I was not using the batch properly, because in certain points of the game the FPS go down pretty much. But I was wrong, the problem wasn’t in the batchnode, was that I wasn’t using the AnimationCache. Now, we have better performance, but I think that still it can be improved. I will keep investigating.