I found that with cc.game.restart()
I can restart a game.
But that shows the splash screen. How could I restart a game without showing the splash screen?
I found that with cc.game.restart()
I can restart a game.
But that shows the splash screen. How could I restart a game without showing the splash screen?
From the source code I found I can do that with the following code in the main.js
:
cc.game.onStart = function(){
//load resources
cc.view.setDesignResolutionSize(640, 480, cc.ResolutionPolicy.SHOW_ALL);
cc.LoaderScene.preload(gameResources, function () {
cc.director.runScene(new GameScene());
}, this);
};
cc.game.onRestart = function(){
cc.view.setDesignResolutionSize(640, 480, cc.ResolutionPolicy.SHOW_ALL);
cc.director.runScene(new GameScene());
};
cc.game.restart = function () {
cc.director.popToSceneStackLevel(0);
cc.audioEngine && cc.audioEngine.end();
cc.game.onRestart();
}
cc.game.run();
It is not necessary to preload resources again for the restarted level.
So does the code solved your problem?
If not, i have some questions on your problem.
cc.game.restart()
should work like reopen the app.
But i think you just need to replace with a new scene by using
cc.director.runScene(new GameScene());
The code I pasted solved my issue, but as I see from your reply,
cc.director.runScene(new GameScene());
is really all I need. Thanks!