0
votes

How can I create CCSprites composed of multiple sub-sprites while using spritesheets?

For example, my game has a wizard with multiple frames. He is drawn to a CCSpriteBatchNode that contains all his frames. I want to add items to the wizard, like a staff, etc. The staffs are on another sprite sheet.

Normally, I would think of adding the staff sprite to the parent wizard sprite, and position the staff relative to the wizard. But obviously that throws an error, because the staff should be drawn to a batch node containing the staff, right?

How do you manage layered/composed sprites with CCSpriteBatchNode?

2
I dont use batch nodes for animations : if you think about it, you only have one frame at a time, so you dont really benefit from the so taunted 'performance improvement'. So i do these animations with normal sprite animations, and am free to add whatever i want as children to the soldier's animation (health bar, damage sprites , etc ...), without having to torture myself with batch nodes' constraints.YvesLeBorg
@YvesLeBorg That makes lots of sense. I was mixing up using CCSpriteBatchNodes with the decision to put all my stuff into spritesheets. They are separate decisions. Thanks!Sean Clark Hess

2 Answers

1
votes

Of course you should use CCSpriteBatchNode because of performance. It's impossible to use texture up to 2048x2048 for your batch node. you should create two CCSpriteBatchNode. One for your wizard and another for your items and position them relative to your wizard.

0
votes

I decided to not use a batch node, as YvesLeBorg described, it's not necessarily that big of a performance gain for keyframe animations.

Simply moving to spritesheets enabled my app to load quickly with lower memory, and it runs fine. Since you have to give up the ability to position things relatively with CCSpriteBatchNodes, it's not worth it unless the performance is already bad.