0
votes

I've been trying to wrap my head around this, and I haven't found any good explanation in the docs or the forum or here, so here goes:

Can I combine CCSpriteBatchNode with CCAnimations? If so, how? Can you give a code example?

I understand that a CCAnimation could be defined with frames coming from several different cached textures (CCTexture2D / CCTextureCache), but a CCSpriteBatchNode must only refer to exactly one texture.

I guess this amounts to several separate sub-questions:

  1. Can I animate a Sprite I have handed as child to a CCSpriteBatchNode with a CCAnimation? Will that still give me the Batch speed advantage? And will an error occur if the CCAnimation refers to frames on separate textures?

  2. In theory , I could define an animation with frames from different textures, hence they would have to be from different CCSpriteBatchNodes, correct? Or is that impossible?

  3. Can I have several different sprites on one CCSpriteBatchNode, each calling up CCAnimations whose frames are defined on that Batch node, all from the same CCSpriteBatchNode's Texture?

Thanks to anybody who can spend a minute to explain this to me!

1

1 Answers

0
votes
  1. You can animate a sprite that is part of a CCSpriteBatchNode. What you refer to as "batch speed advantage", is the number of opengl calls that are made. If all your sprites use the same CCSpriteBatchNode, then you make fewer calls. Your CCAnimation basically just plays sprites in a sequence with a delay.You cannot add a sprite to a CCSpriteBatchNode that is not part of the same texture. This is something you can try yourself instead of asking this question.

  2. I think you don't understand how CCSpriteBatchNodes & CCAnimations work. They are two separate things. Your animation can refer to sprites that are part of different textures, but if the sprite you are animating is on a spritebatchnode, then you should animate it only with sprites which are of that texture.

3.Yes.

You should really spend some time reading up on cocos2d forums, as well as other tutorials, since these are fundamental issues. After that it would be much easier for you to code. There are also several books on cocos2d that cover fundamentals.