tags:

views:

76

answers:

1

Hello, I'm using Cocos2D in my project and I'm quite new to this library. And I don't understand one thing.

I have many sprites on the scene which are added and removed constantly. So at certain moment a sprite becomes useless and I have to remove it form a batch node.

In the comments of the removeChild method of CCSpriteBatchNode class is said:

 @warning Removing a child from a CCSpriteBatchNode is very slow

Does anybody know what the best method of removing a sprite?

Thanks!

A: 

Instead of adding and removing sprites why not re use them, then you won't have any slow down caused by adding or removing sprites.

Setting a sprite not to be visible saves the render cost and when you need to add it again just move it to position and the texture frame if you need to and then turn the visibility back on.

I subclass a ccSprite and then add them to an array to keep track of active and inactive sprites.

Dave.

ddeaco