cocos2d-js-v3.2-rc0
cc.director.end();//退出app cc.Application.getInstance().openURL("http://www.baidu.com");//openurl
检测android下的返回键和menu键,可以用下面这段代码
cc.eventManager.addListener({event: cc.EventListener.KEYBOARD,onKeyReleased: function(keyCode, event) { if(keyCode == cc.KEY.back) { cc.director.end(); } else if(keyCode == cc.KEY.menu) { } }}, this);
添加js以后,修改project.json,大概弄成类似这样,具体的看cocos2d js下面的sample或者是main.js里面的说明
project.json
{ "project_type": "javascript", "debugMode" : 1, "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", "renderMode" : 0, "engineDir":"frameworks/cocos2d-html5", "modules" : ["cocos2d"], "jsList" : [ "src/resource.js", "src/helloWorldScene.js", "src/helloWorldLayer.js" ] }