方法一:移動也會判斷成輕按兩下
onTouchesEnded:function(touches, event) {
var touchOne =touches[0];
var str = touchOne.getPreviousLocation().x + "\n" + touchOne.getLocation().x;
this._logLabel.setString(str);
if (Math.abs(touchOne.getDelta().x) <=6 && Math.abs(touchOne.getDelta().y) <=6 ) {
var bigger = cc.ScaleBy.create(3, 2); //變大
var smaller = bigger.reverse(); // 恢複
this._ship.runAction(cc.Sequence.create(bigger,smaller));
}
},
onTouchesEnded:function(touches, event) {
var touchOne =touches[0];
var str = "原坐标:" + "\n"
+ this._lastTouchPos.x + "\n"
+ this._lastTouchPos.y + "\n"
+ "新坐标:" + "\n"
+ touchOne.getLocation().x + "\n"
+ touchOne.getLocation().y + "\n"
this._posLabel.setString(str);
// 有效輕按兩下判定,隻有距離,沒加上輕按兩下時間判定
if (Math.abs(cc.pDistance(touchOne.getLocation(),this._lastTouchPos)) < 20) {
this.onCaptainSkill(null);
}
else {
this._lastTouchPos = touchOne.getLocation();
}
},
onTouchesMoved:function (touches, event) {
this._posLabel.setString("移動");
this._lastTouchPos = cc.p(0,0);
this.processEvent(touches[0]);
},