【craetor发布5/365】单点触摸

单点触摸

creator里如何实现单点触摸呢?
event.getTouches()可以获取触摸点列表
主要是用getID()来判断

// 单点触摸
        this.mSprite.on('touchstart', function(event){
            console.log('111a',event.getTouches(), event.getID());
            if(G.gTouchId != 0){
                return;
            }
            G.gTouchId = event.getID();
            // do something
        })
        this.mSprite.on('touchmove', function(event){
            console.log('111b',event.getTouches(), event.getID());
            if(G.gTouchId != event.getID()){
                return;
            }
            // do something
        })
        this.mSprite.on('touchend', function(event){
            console.log('111c',event.getTouches(), event.getID());
            if(G.gTouchId != event.getID()){
                return;
            }
            G.gTouchId = 0;
            // do something
        })
        this.mSprite.on('touchcancel', function(event){
            console.log('111c',event.getTouches(), event.getID());
            if(G.gTouchId != event.getID()){
                return;
            }
            G.gTouchId = 0;
              // do something
        })

你可能感兴趣的:(【craetor发布5/365】单点触摸)