cocos2d-xcocos2d-jscocoscreator

How to navigate between scenes Cocos creator?


I'm working with cocos creator v 1.3.1

I want to know how to navigate between scenes, Let say we have to scenes SceneA and SceneB.

First game load SceneA after that I can load second scene by calling this function cc.director.loadScene('SceneB');

After the I want to load SceneA, if I call like this cc.director.loadScene('SceneA');

It load new instance of SceneA but I want to load previous instance of SceneA.

How can I do it?


Solution

  • I think this is what the scene stack is for.

    cc.director.pushScene('SceneB');
    

    will pause SceneA and start executing SceneB.

    cc.director.popScene();
    

    will exit from SceneB and unpause SceneA with its previous state intact.