Switching scene back and forth, the init function and children added in the init function

Ok so in the init function I add a couple of buttons with some tags so I can easily identify them.
I click one of the buttons and I do a delegate method where I switch to a different scene. But before that I remove these buttons. 1st time this works perfect.

So then it goes to a second scene… Then I simply do in the onTouchesBegan function in this second scene a transition back to the original scene.

CCScene* pScene=FirstScene::create();
CCDirector::sharedDirector()->replaceScene(CCTransitionMoveInL::create(0.5f,pScene));

Buttons are added correctly on screen but when I click button to switch to second scene again it tries to remove the buttons by tags, but it says they don’t exist (cocos2d: removeChildByTag(tag = 801): child not found!)!
it’s like the stuff added to the init function doesn’t belong to the current scene or something once the scene has been created once and then is switch back and forth to.

Figured it out!

Remember to do:
Director::getInstance()->getEventDispatcher()->removeAllEventListeners();

Else they will keep on stacking those you add in the init :smiley: