zoukankan      html  css  js  c++  java
  • 双击判断

    方法一:移动也会判断成双击 

    onTouchesEnded:function(touches, event) {
    
            var touchOne =touches[0];
            var str = touchOne.getPreviousLocation().x + "
    " + 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 = "原坐标:" + "
    "
                + this._lastTouchPos.x + "
    "
                + this._lastTouchPos.y + "
    "
                + "新坐标:" + "
    "
                + touchOne.getLocation().x + "
    "
                + touchOne.getLocation().y + "
    "
            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]);
        },
  • 相关阅读:
    sql random string
    ubuntu 16.04中文输入法安装
    ubuntu修改docker源
    osm3ge
    ubuntu配置环境变量 sudo gedit /etc/profile
    斐波那契数列中获取第n个数据值
    为什么redis使用单线程还能这么快?
    Redis使用规范
    redis性能提升之pipeline
    centos7 用yum安装java8
  • 原文地址:https://www.cnblogs.com/linn/p/3501914.html
Copyright © 2011-2022 走看看