Skip to content

Commit ed7fc5c

Browse files
committed
game.restart() return a promise on native platforms
1 parent cc2ff78 commit ed7fc5c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

platforms/native/engine/jsb-game.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@
2424
****************************************************************************/
2525

2626
cc.game.restart = function () {
27-
// Need to clear scene, or native object destructor won't be invoke.
28-
cc.director.getScene().destroy();
29-
cc.Object._deferredDestroy();
30-
__restartVM();
27+
return new Promise((resolve) => {
28+
// Need to clear scene, or native object destructor won't be invoked.
29+
cc.director.getScene().destroy();
30+
cc.Object._deferredDestroy();
31+
__restartVM();
32+
33+
// Resolve the promise to indicate completion
34+
resolve();
35+
});
3136
};
3237

33-
jsb.onError(function (location, message, stack) {
38+
jsb.onError((location, message, stack) => {
3439
console.error(location, message, stack);
3540
});
3641

0 commit comments

Comments
 (0)