Hello developers! I want delete my all sprites from scene how can I do it?
How are you storing your sprites? In a vector? If so loop through and removeFromParentAndCleanup()
I’m storing with this way:
square = Sprite::create("squareNormal.png");
square->setPosition(Vec2(touch->getLocation().x, touch->getLocation().y));
It’s deleting buttons when I run this code removeFromParentAndCleanup(true);
It’s work but I don’t want delete my buttons. I want delete only sprites.
I can suggest three options:
-
store all sprites in your vector or list.
When want to delete go through all sprites and call removeFromParentAndCleanup() -
When want to delete go through all childs of parent (scene?) and check is it sprite.
If so call removeFromParentAndCleanup()
To check is it sprite:if (dynamic_cast<Sprite*>(childNode)) -
Add sprites to separate parent node.
When want to delete go through all childs of parent node and call removeFromParentAndCleanup()
Thank you for reply! I will try your options.
You should choose one option 
Ahaha 


I always lean towards 1 mostly for my needs. I’m all for portable containers 