var listener = {
event: cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchBegan: function (touches, event) {
var goAction= cc.moveBy(0.2,cc.p(0,140));
this.node.runAction(goAction);
return true; //这里必须要写 return true
},
onTouchMoved: function (touches, event) {
},
onTouchEnded: function (touches, event) {
},
onTouchCancelled: function (touches, event) {
}
}
cc.eventManager.addListener(listener, this.node);
或者
this.canvas.on(cc.Node.EventType.TOUCH_START, function (event) {//this.canvas当前画布
var touches = event.getTouches();
var touchLoc = touches[0].getLocation();
}, this.node);
this.canvas.on(cc.Node.EventType.TOUCH_MOVE, function (event) {
var touches = event.getTouches();
var touchLoc = touches[0].getLocation();
}, this.node);
this.canvas.on(cc.Node.EventType.TOUCH_END, function (event) {
}, this.node);