我用了touch_start触发事件,但是用这个只能拖动。我想要的效果是,点一下一个棋子,再点一下屏幕,到屏幕上点击的地方。如果点击的是棋子右边,向右走一格,如果是左边,向左走一格。
我用touchend触发,但是不行。代码如下。问题是,如何实现,得到点击屏幕上那点的坐标?目前必须点击这个棋子,点击到屏幕就无效。如有答复,先谢谢了!
onTouchEnd (event) {
//var cpos=this.node.convertToNodeSpaceAR(event.getLocation());
var cpos=event.getLocation(); 注意:不管转不转坐标,都不行,无法实现判断x2>x1
var x2=cpos.x;
var y2=cpos.y;
if(this.xvalue>3){this.xvalue=3;}
if(this.yvalue>7){this.yvalue=7;}
if(x2>x1 ){
this.node.x =x1+64.8;
this.xvalue=this.xvalue+1; //mcount=1;
}else{
this.node.x =x1-64.8;
this.xvalue=this.xvalue-1;}
}

