cocos creator 1.5.0
安卓平台,返回按键的监听,在第1个场景有效,进入第2个场景后就无效了
代码如下:
onLoad: function () {
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUpBack, this);
},
onDestroy: function(){
cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUpBack, this);
},
onKeyUpBack:function(event){
switch(event.keyCode) {
case cc.KEY.back:
cc.director.end();//退出应用
break;
}
},