按需要增减代码
onLoad () {
this.node.on(‘touchstart’,this.onTouchStart,this);
this.node.on(‘touchmove’,this.onTouchMove,this);
}
onDestroy(){
this.node.off(‘touchstart’,this.onTouchStart,this);
}
onTouchStart(e){
console.log(‘点击开始’);
}
onTouchMove(e){
let delta=e.getDelta();
this.node.x+=delta.x;
this.node.y+=delta.y;
}
cocos creater touch事件物体跟随鼠标移动(亲测可用)
最新推荐文章于 2022-02-28 18:17:09 发布