I can't add a sprite to CCSpriteBatchNode

I can't add a sprite to CCSpriteBatchNode
0.0 0


Hi all,

I’m trying to add a sprite to a CCSpriteBatchNode but its causing a crash at the line:

@ CCAssert(dynamic_cast<CCSprite*>(child) != NULL, “CCSpriteBatchNode only supports CCSprites as children”);@ in the file CCSpriteBatchNode.cpp.

I have other sprites attached to this node using the same texture atlas. And the sprites I’m adding to the spritebatch were previously attached to a layer.
I’ve made sure I’m removing them from the layer first before adding them to the spritebatch.

Can anyone tell me why this is crashing?


you have many examples on how to use the ccspritebatchnode at the “tests” project… “Sprites” folder.

Good luck :slight_smile:


Yes, you can only add CCSprite object to a SpriteBatch.
If you are adding something else, like a CCLayer, it will cause a crash.