Reputation: 43
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?
Upvotes: 3
Views: 3414
Reputation: 49
cc.director.loadScene(scene-name) is the official way to exchange two scene
Upvotes: 1
Reputation: 46
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.
Upvotes: 3
Reputation: 43
I have an idea you can persist the data (or state) you need in SceneA before you load SceneB, and when you come back to SceneA you can read the data (or state) persisted. If you need switch between SceneA and SceneB frequently you may use cc.game.addPersistRootNode(this.xxx)
Upvotes: 1