ccc 单点触控

cc.Class({
    extends: cc.Component,

    properties: {

    },

    // use this for initialization
    onLoad: function () {
        this.registerTouch()
    },

    registerTouch:function () {
        var self=this
        
        cc.eventManager.addListener({
            event: cc.EventListener.TOUCH_ONE_BY_ONE,

            //开始
            onTouchBegan: function(touch, event) {
                cc.log("began")

                return true; // don't capture event
            },

            //移动
            onTouchMoved: function( touch, event) {
                cc.log("moved")
            },
            
            //结束
            onTouchEnded: function(touch, event) {
                cc.log("end")
            }
        }, self.node);
    }

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});

posted @ 2016-06-24 23:40  yufenghou  阅读(140)  评论(0)    收藏  举报