Hi there,
I have a multi-scene project and I move between scenes using repalceScene.
When I move from one scene to another, it remembers my touch events. For example, if I click the Credits button from the main menu I can tap anywhere on the screen to return to the main menu. Now if I tap on a empty part of the screen on the menu scene it calls “Director::getInstance()->replaceScene(TransitionRotoZoom::create(1, scene));” again, reloading the MenuScene along with transition effect.
I can’t see why it’s doing this. Does anyone have any ideas?
I create the scene with:
Scene* CreditsScene::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = CreditsScene::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
Create my touch like this:
//Touch listener
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = CC_CALLBACK_2(CreditsScene::TouchBegan, this);
getEventDispatcher()->addEventListenerWithFixedPriority(touchListener, 100);
And call replaceScene like this:
void CreditsScene::returnToMenu()
{
//Returns to MenuScene
auto scene = MenuScene::createScene();
Director::getInstance()->replaceScene(TransitionRotoZoom::create(1, scene));
}
This also happens when I go from my GameScene back to my MenuScene, but that causes the app to crash.
I’d really appreciate it if someone could point me in the wrong direction!
Thanks