cc.Class({
extends: cc.Component,
properties: {
img_map: {
default: null,
type: cc.Sprite
}
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.img_map.node.on(cc.Node.EventType.TOUCH_START,function(t){
console.log("触摸开始");
},this)
//监听
this.img_map.node.on(cc.Node.EventType.TOUCH_MOVE,this.on_touch_move,this);
//this.node.on(cc.Node.EventType.TOUCH_MOVE,this.on_touch_move,this);
//触摸抬起
this.img_map.node.on(cc.Node.EventType.TOUCH_ENDED,function(t){
console.log("触摸内结束");
},this);
this.img_map.node.on(cc.Node.EventType.TOUCH_CANCEL,function(t){
console.log("触摸外开始");
},this);
},
on_touch_move(t){
//定义一个n_pos变量存储当前触摸点的位置
var n_pos=t.getLocation();
console.log(n_pos,n_pos.x,n_pos.y);
var delta=t.getDelta();
this.img_map.node.x+=delta.x;
this.img_map.node.y+=delta.y;
},
start () {
},
// update (dt) {},
});