1、给一个Layer添加触摸事件,前提需要在cocos studio当中吧panel的交互去掉,不然会不能自定义其触摸事件,
cc.eventManager.addListener({
prevTouchId: -1,
event: cc.EventListener.TOUCH_ALL_AT_ONCE,255)">
onTouchesEnded:function (touches,event) {
var touch = touches[0];
cc.log("onTouchesEnded");
}
},this);
var root = ccs.uiReader.widgetFromJsonFile(res.game01Controller_json);
this.addChild(root,1);
this.btn_darts=ccui.helper.seekWidgetByName(root,"btn_darts");
this.btn_darts .addTouchEventListener(this.dartsTouchEvent,this);