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]);
        },
  • 相关阅读:
    java 包
    数据库查询操作练习
    solr全文检索实现原理
    前端页面设计问题小计
    送给自己的九封信
    bootstrap-table初使用
    bootstrap-treeview初使用
    windows:plsql配置oracle连接
    maven的安装和配置
    cxf+spring+restful简单接口搭建
  • 原文地址:https://www.cnblogs.com/linn/p/3501914.html
Copyright © 2011-2022 走看看