方法一:移动也会判断成双击
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]); },