Creating Batch Node from set of PNGs

Hi,
I am planning to implement batch node animation using set of PNGs (instead of using a spritesheet generated from external tool) by the following way:-

i) Generate animation from the PNG set.
ii) Generate a texture which is combination of all the PNG to be used in the animation.
iii) Use the texture generated in step (ii) to generate batch node.

Please tell what will be the disadvantages of using this approach vs the approach of using spritesheet generated by an external tool.

That’s almost the approach I use. Except that in step 2 I use TexturePacker.

For example I have a folder “Zombie01” that has all Zombie01 frames: zomb01_move_00.png, zomb01_move_01.png,… etc

TexturePacker will create a spritesheet and plist using the folder of PNGs.

I then place the Zombie01.png and Zombie01.plist in my resources folder and use the following:

    CCTextureCache::sharedTextureCache()->addImage("Zombie01.png");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Zombie01.plist", "Zombie01.png");

The advantages are that it renders faster than non-batch and its easy to do.

@Kevin
Through the approach i have mentioned i am trying to remove the use of an external tool to create a sprite sheet. So would like to know will this approach will produce any performance issues ??

No. CCSpriteBatchNode can only speed up the performance if its child leaves (via batchNode->addChild(CCNode*)) use the same texture.
As the matter of fact, we check this condition in CCSpriteBatchNode::addChild(CCNode *child, int zOrder, int tag)

// check CCSprite is using the same texture id
CCAssert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName(), "");

TexturePacker or Zwoptex is recommended.

How about this… WHY are you trying to not use the 3rd party tool?

If you make a plist manually (you can do that, it’s just XML) and use a single texture, you will have the exact same performance as if you used a program to make the plist. It will just be a lot more work.

If you do not use a plist than you have no way of getting the “frames” out of the master png and cannot use batch nodes.