Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top