Unable to restart the Coco2D app.


#1

I have a button when hit, the app would start

var myApp=new cocos2dApp(MainLayer);

var MainLayer=cc.Layer.extend({
ctor:function () {
this.*super;
layer = new MyFirstApp; //global layer OK
layer.init;
this.addChild;
},
});
*So, when I hit the close the button, I stop the app_

this.unscheduleAllSelectors();
this.removeFromParentAndCleanup(true);
cc.AudioEngine.getInstance().stopBackgroundMusic();
cc.Application.sharedApplication().applicationWillTerminate();

So, I want to restart the app by hitting the button again,

var myApp=new cocos2dApp(MainLayer);

var MainLayer=cc.Layer.extend({
ctor:function () {
this.*super;
layer = new MyFirstApp; //global layer OK
layer.init;
this.addChild;
},
});

*However, the second time it won’t restart. Only the very first time does the app works, not the second, third times….etc._


#2

I am sorry. It can’t removed by button currently.
However, you may try pause and restart instead of remove it.